[SQL Server] 循环游标执行-无事务
From: https://blog.csdn.net/weixin_42609389/article/details/126955029
begin
declare @a int
declare @temp varchar(50)
set @a=1
declare order_cursor cursor for (select [CMID] from [Warehouse].[MT].[Customers])
open order_cursor
fetch next from order_cursor into @temp
while @@FETCH_STATUS = 0
begin
update [Warehouse].[MT].[Customers] set CMCode=@a where [CMID]=@temp
set @a=@a+1
fetch next from order_cursor into @temp
end
close order_cursor
deallocate order_cursor
end
go
浙公网安备 33010602011771号