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

Error converting data type nvarchar to datetime

$
0
0

[Using SQL Server 2008 R2 Enterprise x64 SP1]

I am trying to use some form of GETDATE() to pass today's date to a stored procedure inside OPENQUERY(), but I keep getting the error

Msg 8114, Level 16, State 1, Procedure spCalcProjection, Line 0
Error converting data type nvarchar to datetime

Here is the code:

SELECT top 1 multi FROM OPENQUERY([production], 'exec proddb.dbo.spCalcProjection "GETDATE()"')
If I use 2014-05-22 or any literal in place of GETDATE() then I have no problem and get the correct, expected result. If I use some other functionality likeCAST(GETDATE() AS DATE) or CONVERT(varchar, GETDATE(), 112) then I get the above error again.

Viewing all articles
Browse latest Browse all 23857

Trending Articles



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