我不知道如何解決這個錯誤:運行sp_executesql的查詢需要參數@statement
過程或函數「sp_executesql的」需要參數「@statement」,但未提供。
此查詢:
DECLARE @a INT
DECLARE @b VARCHAR
SET @a = 1
WHILE @a < 30
BEGIN
set @b = @a
exec sp_executesql update source_temp set pmt_90_day = pmt_90_day + convert(money,'trans_total_'[email protected])+N'
N'where convert(datetime,'effective_date_'[email protected])+N' <= dateadd(day,90,ORSA_CHARGE_OFF_DATE)
and DRC_FLAG_'[email protected] = 'C'''
SET @a = @a + 1
END
而且,你能幫助我理解N的正確使用方法」,如果它的這一說法正確。
感謝您的幫助。
我試圖在一個循環中動態地運行我的更新,所以每次迭代更新字段的增量爲1.它是從http://stackoverflow.com/questions/753947/using-while-loop-for -SQL-服務器更新 – homerjay 2009-04-16 16:26:30
例如:迭代1使用effective_date_1,迭代2使用effective_date_2等 – homerjay 2009-04-16 16:27:20