遊標小樣

cursor example

 

declare   @i   int     ,   @a   varchar(20)
declare   cur_cursor   cursor  
    for  
      select   a   from   table1

set   @i=1
while   @i<=10
begin
  open   cur_cursor
  fetch   cur_cursor   into   @a
  while   @@fetch_status=0
      begin
          do.....somethings
          feccht   next   cur_cursor   into   @a    
      end  
  close   cur_cursor
  deallocate   cur_cursor
  set   @i=@i+1
end

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章