小记:正确使用游标

declare @Id int
declare item_cursor cursor local for  SELECT  A.Id FROM  A 

open item_cursor 
     FETCH NEXT FROM item_cursor INTO @Id
     while @@FETCH_STATUS = 0
     begin
       ....................................

      FETCH NEXT FROM item_cursor INTO @Id
     end 
    close item_cursor
    deallocate item_cursor     --一定得记得在关闭之后要释放游标
posted @ 2009-10-14 14:52  驹无尚者  阅读(112)  评论(0)    收藏  举报