insert into b select id,name from a where not exists (select 1 from b where id = a.id)
insert into B库.dbo.B1 select id,name from A库.dbo.A1 a where not exists(select 1 from B库.dbo.B1 where id=a.id)
insert into B.b select id,name from A.a where not exists (select 1 from B.b where id = A.a.id)
insert into B..b select id,name from A..a t where not exists (select 1 from b where id = t.id)不同数据库
insert into B.dbo.B select id,name from A.dbo.A a where not exists(select 1 from B.dbo.B where id=a.id)
仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 B.dbo.B 中为标识列指定显式值。
set identity_insert B..b oninsert into B..b(id,name) select id,name from A..a t where not exists (select 1 from b where id = t.id)set identity_insert B..b off
select id,name
from a
where not exists (select 1 from b where id = a.id)
select id,name from A库.dbo.A1 a
where not exists(select 1 from B库.dbo.B1 where id=a.id)
select id,name
from A.a
where not exists (select 1 from B.b where id = A.a.id)
select id,name
from A..a t
where not exists (select 1 from b where id = t.id)不同数据库
into B.dbo.B
select
id,name from A.dbo.A a
where
not exists(select 1 from B.dbo.B where id=a.id)
中为标识列指定显式值。
set identity_insert B..b oninsert into B..b(id,name)
select id,name
from A..a t
where not exists (select 1 from b where id = t.id)set identity_insert B..b off