I am facing the problem to convert into datetime..
DECLARE @sql nvarchar(max)
DECLARE @Lastdate datetime
SET @Update = N'
SELECT TOP 1
'+@Lastdate+' = Purchase.LastUpdated
FROM Purchase
WHERE ID = 15
'
LastUpdated is also datetime format in database
Then why It cannot convert
I want to set the datetime into declared variable @LastDate from purchase.lastupdate using sp_executesql only