一个简单的SqlServer游标使用

declare @id int
declare @name nvarchar(100)
declare c_department cursor for
  select id,name from department
open c_department
fetch next from c_department into @id,@name
while @@FETCH_STATUS=0
begin 
  --代码
  --代码
  fetch next from c_department into  @id,@name
end
close c_department
deallocate c_department

 

posted @ 2016-06-16 23:16  蒹葭白露  阅读(5264)  评论(0编辑  收藏  举报