简单----------------------------- insert 数据库B..表2 select * from 数据库A..表1
if 如果冲突以表1为准 update a set col1=b.col1,..... from a..表1 a,b..表2 a where a.key=b.key else update b set col1=b.col1,..... from a..表1 a,b..表2 a where a.key=b.keyinsert a..表1 select * from b..表2 a where not exists ( select 1 from a..表1 where key=a.key )insert a..表1 select * from b..表2 a where not exists ( select 1 from a..表1 where key=a.key )
if 如果冲突以表1为准 update a set col1=b.col1,..... from a..表1 a,b..表2 a where a.key=b.key else update b set col1=b.col1,..... from a..表1 a,b..表2 a where a.key=b.keyinsert a..表1 select * from b..表2 a where not exists ( select 1 from a..表1 where key=a.key )insert b..表2 select * from a..表1 a where not exists ( select 1 from b..表2 where key=a.key )
被导入表存在 用insert into A select * from B 不存在 select * into A from B
select * from A..TABLE1
select * from A..TABLE1
insert 数据库B..表2
select * from 数据库A..表1
if 如果冲突以表1为准
update a
set col1=b.col1,.....
from a..表1 a,b..表2 a
where a.key=b.key
else
update b
set col1=b.col1,.....
from a..表1 a,b..表2 a
where a.key=b.keyinsert a..表1
select * from b..表2 a
where not exists (
select 1 from a..表1
where key=a.key
)insert a..表1
select * from b..表2 a
where not exists (
select 1 from a..表1
where key=a.key
)
update a
set col1=b.col1,.....
from a..表1 a,b..表2 a
where a.key=b.key
else
update b
set col1=b.col1,.....
from a..表1 a,b..表2 a
where a.key=b.keyinsert a..表1
select * from b..表2 a
where not exists (
select 1 from a..表1
where key=a.key
)insert b..表2
select * from a..表1 a
where not exists (
select 1 from b..表2
where key=a.key
)
不存在 select * into A from B
2 也可以用DTS
不用代碼就可以實現