循环更新sqlserver数据库表ID

DECLARE @a INT
DECLARE aaa CURSOR for select columnID from LNDB_COLUMN_INFO where columnID BETWEEN 223899 AND 224003
OPEN aaa
FETCH next from aaa into @a
WHILE @@fetch_status=0
BEGIN
print @a
update LNDB_COLUMN_INFO SET columnID=@a-223910 where columnID=@a
FETCH NEXT from aaa into @a
END
CLOSE aaa
DEALLOCATE aaa

原文地址:https://www.cnblogs.com/ninicwang/p/9711914.html