declare cursor yourcursor for /*说明:yourcursor为你定义的游标名 yourtable 为你定义的要接收每一个表名的变量 Bdatabase和Adatabase分别表示B表所在数据库名称和A表所在数据库名称 注意:这段代码不能直接执行,需要调试 */ SELECT Bdatabase.dbo.sysobjects.name FROM Bdatabase.dbo.sysobjects WHERE (xtype = 'u') ORDER BY name Fetch next from yourcursor into yourtable while @@fetchstatus=0 begin insert Bdatabase.dbo.B select * from Adatabase.dbo.A delete Adatabase.dbo.A end
别忘记在最后加上如下代码: close yourcursor deallocate yourcursor 还就在Fetch...前加open yourcursor 匆忙,呵呵... 我可是想得分的哟!~^~
/*说明:yourcursor为你定义的游标名
yourtable 为你定义的要接收每一个表名的变量
Bdatabase和Adatabase分别表示B表所在数据库名称和A表所在数据库名称
注意:这段代码不能直接执行,需要调试
*/
SELECT Bdatabase.dbo.sysobjects.name
FROM Bdatabase.dbo.sysobjects
WHERE (xtype = 'u') ORDER BY name
Fetch next from yourcursor
into yourtable
while @@fetchstatus=0
begin
insert Bdatabase.dbo.B
select * from Adatabase.dbo.A
delete Adatabase.dbo.A
end
close yourcursor
deallocate yourcursor
还就在Fetch...前加open yourcursor
匆忙,呵呵...
我可是想得分的哟!~^~