0
請參閱下面的TSQL:SELECT TOP @Variable導致錯誤: 「無效語法」
declare @NicheDailyDeletionVolume int
select @NicheDailyDeletionVolume = NicheDailyDeletionVolume FROM [hq-svr-sql-05].genie2delete.dbo.dbsystem
declare @tsql as nvarchar(200)
set @tsql = 'update tbx_rrdgeniestaging set addedtime = dateadd(d,-29,getdate()) where eventid in (
select distinct top '' + @NicheDailyDeletionVolume + '' eventid from tbx_rrdgeniestaging where candelete=getdate())'
EXECUTE sp_executesql @tsql
我得到的錯誤是:近 '+ @NicheDailyDeletionVolume +' 的語法不正確。
我以前卻從未與TOP使用這樣的變量。
'WHERE candelete = GETDATE()'是極不可能做你想要什麼。不清楚是什麼數據類型'candelete'是從名字,但是從'GETDATE()'你真的想作爲一個查詢碰巧被執行與確切時間下降到milisecond僅匹配那些行比較假定日期時間? – 2014-11-14 15:12:22