C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着
--声明一个游标
  Declare curtable2 Cursor
    for
  Select AnnounceID From table2     

  Declare @AnnounceID int
  Declare @body  varchar(30)

--初始化
  Set @AnnounceID=0
  Set @body=''

  --打开游标
  Open curtable2

  --循环并提取记录
  Fetch Next From curtable2 Into @AnnounceID   
  While ( @@Fetch_Status=0 )   
  begin
--更新到汇总表。

        set @body=(select table2.body from table2 where table2.AnnounceID=@AnnounceID )

    if (@body is not null and @AnnounceID in (select dv_bbs1.AnnounceID from dv_bbs1))
   begin
        Update dv_bbs1 Set dv_bbs1.body=(@body) where dv_bbs1.AnnounceID=@AnnounceID
        print @AnnounceID
   end
Fetch Next From curtable2 Into @AnnounceID   
      

end

  --关闭游标   
  Close curtable2

  --释放游标
  Deallocate curtable2
posted on 2008-08-09 16:03  王德田  阅读(192)  评论(0编辑  收藏  举报