SQL游标示例

游标示例:

 总记不住这个游标怎么写,现在把格式写下,作为记录吧

 decalre @c1  varchar(30)
 deckare @c2  varchar(30)
 declare my_curcor  cursor
 for( select   c1 ,c2  from  table)
 open my_curcor  into @c1  @c2 
 fetch next from  my_curcor into  @c1  @c2 
 while (@@fetch_status=0)
 begin
   //to  do
   fetch next from  my_curcor into  @c1  @c2 
 end
 close my_curcor
 deallocate   my_curcor

posted @ 2017-03-14 17:31  王宝会  阅读(113)  评论(0编辑  收藏  举报