使用游标 循环遍历查询结果集

 

 

 declare @id int
 declare @biz nvarchar(50)

 declare cursor1 cursor for (select id,biz from account)
 open cursor1
  
 while @@FETCH_STATUS = 0    --返回被 FETCH语句执行的最后游标的状态--
 begin        
 fetch next from cursor1 into @id,@biz
 update [newrank_fans] set biz=@biz  where accountid=@id         
 end            
 close cursor1  --关闭游标
 deallocate cursor1   --释放游标

 

posted on 2018-01-10 09:37  奔游浪子  阅读(141)  评论(0)    收藏  举报

导航