insert into ku1..lb1
select * from ku2..lb1 t2 where t2.leavedate is not null and id=7002insert into ku1..lb2
select * from ku2..lb2 t2 where t2.leavedate is not null and id=7002insert into ku1..lb3
select * from ku2..lb3 t2 where t2.leavedate is not null and id=7002insert into ku1..lb4
select * from ku2..lb4 t2 where t2.leavedate is not null and id=7002

解决方案 »

  1.   

    use ku2
    goinsert into ku1..lb1 select * from lb1 where leavedate is not null and ID = 7002
    insert into ku1..lb2 select * from lb2 
    insert into ku1..lb3 select * from lb3  
    insert into ku1..lb4 select * from lb4
      

  2.   

    insert into ku1.dbo.lb1 select * from ku2.dbo.lb1 t2 where t2.leavedate is not null and id=7002
    insert into ku1.dbo.lb2 select * from ku2.dbo.lb2 t2 where t2.leavedate is not null and id=7002
    insert into ku1.dbo.lb3 select * from ku2.dbo.lb3 t2 where t2.leavedate is not null and id=7002
    insert into ku1.dbo.lb4 select * from ku2.dbo.lb4 t2 where t2.leavedate is not null and id=7002
      

  3.   

    if exists (select 1 from ku2..lb1 as t2 where t2.leavedate is not null and id='7002')
    begin
     insert into ku1..lb1 select * from lb1 
     insert into ku1..lb2 select * from lb2 
     insert into ku1..lb3 select * from lb3  
     insert into ku1..lb4 select * from lb4end