如果表结构都是一样的,可以这样 insert 库3..表3 select * from 库1..表1 union all select * from 库2..表2
如果结构都一样则:insert into 库3..表3 select * from 库1..表1 union all select * from 库2..表2
insert into 库3..表3 select * from OPENROWSET('provider_name','datasource' ; 'user_id'; 'password' , 'select * from 库1.dbo.表1') union all select * from OPENROWSET('provider_name','datasource' ; 'user_id'; 'password' , 'select * from 库2.dbo.表2') go如果是垮服务器可以用这个
insert 库3..表3
select * from 库1..表1
union all
select * from 库2..表2
select * from 库1..表1
union all
select * from 库2..表2
insert into 库3..表3
select * from OPENROWSET('provider_name','datasource' ; 'user_id'; 'password' , 'select * from 库1.dbo.表1')
union all select * from OPENROWSET('provider_name','datasource' ; 'user_id'; 'password' , 'select * from 库2.dbo.表2')
go如果是垮服务器可以用这个