Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conversion failed when converting date and/or time from character string in SQLServer

$
0
0

Hi,

I created LinkedServer in SSMS from MYSQL DB.

When i Execute below open Query its working Fine

SELECT * FROM OPENQUERY(MySQL,'call GASP_sales_aps(''2013-04-01 00:00:00'',''2013-05-01 23:23:59'')')

But my problem is when i declared variable and execute below am getting error

declare @dt_start datetime='2013-04-01 00:00:00'
declare @dt_end datetime='2013-05-01 23:23:59'
declare @op datetime
set @op='SELECT * FROM OPENQUERY(MySQL,call GASP_sales_aps(''+@dt_start+'',''+@dt_end+''))'
exec(@op)

"Conversion failed when converting date and/or time from character string."

Can anyone help me where am going wrong?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>