我有一个更新表中超过2000行的过程。
我需要让程序批量运行。我希望它在前10行然后在下10行运行,依此类推。请问我该怎么做。
答案 0 :(得分:0)
类似的东西:
declare @id int
declare c cursor for
select top 10 id
from table
where (needs updating) = 1
open c
fetch next from c into @id
while @@fetch_status = 0
begin
update table
set
(needs to be set) = (value to set),
(needs updating) = 0
where id = @id
fetch next from c into @id
end