开发者

I need to make a stored procedure run in batch

I have a procedure that updates over 2000 rows in a table.

I need to make the procedure run in开发者_StackOverflow batch. I want it to run on the first 10 rows then the next ten and so on. Please how do i go about it.


Something like:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜