我对以下更新声明感到困惑。例如,如果@num = 1
和ntt = 4
。在使用游标时,我想使用num
的初始值.i.e是1.但是我收到的值增加了5.我做错了什么?任何帮助谢谢,我很感激。
UPDATE #temp
SET num = @num,
@num = @num + ntt
DECLARE cur CURSOR LOCAL FORWARD_ONLY DYNAMIC FOR
SELECT yr, id, num FROM #temp
OPEN cur
FETCH cur INTO @yr, @id, @num
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE #TEMP2
SET TRAN_ID = @num,
@num = @num +1
WHERE ...........
FETCH cur INTO @yr, @id, @num
END
答案 0 :(得分:0)
UPDATE
会执行您在SET