--声明一个游标
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
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