sqlserver中有3个数据库,库1.表1,库2.表2,库3.表3
我要把库1.表1,库2.表2中的数据插入到库3.表3中
跪求方案.........谢谢....

解决方案 »

  1.   

    如果表结构都是一样的,可以这样
    insert 库3..表3
    select * from 库1..表1
    union all
    select * from 库2..表2
      

  2.   

    如果结构都一样则:insert into 库3..表3
    select * from 库1..表1
    union all
    select * from 库2..表2
      

  3.   


    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如果是垮服务器可以用这个