首页 » SQL Server » sqlserver 游标小例

sqlserver 游标小例

总忘,小记

declare @c int
declare @seq int
 set @seq=54000101
declare cur cursor for SELECT sectionid
                           FROM StudySection
                              WHERE (yearSemesterID = 2012001)
open cur
   fetch next from cur into @c
   WHILE @@fetch_status=0
    begin
      set @seq=@seq+1
      print @seq
      update StudySection set oracleid=@seq where sectionid=@c
      fetch next from cur into @c
    end
close cur
deallocate cur
打赏

对不起,这篇文章暂时关闭评论。