22,207
社区成员
发帖
与我相关
我的任务
分享
SELECT *
INTO #t
FROM OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ')
update tableA set
col1 = t.col1
,col2=t.col2
,...
from tableA,#t as t
where tableA.bid = t.bid
delete tableA
where not exists (
select 1 from #t as t
where tableA.bid = t.bid
)
insert tableA
SELECT *,其他字段
FROM #t as t
where not exists (
select 1 from tableA
where bid = t.bid
)
drop table #t
update tableA set
col1 = t.col1
,col2=t.col2
,...
from tableA,OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ') as t
where tableA.bid = t.bid
delete tableA
where not exists (
select 1 from OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ') as t
where tableA.bid = t.bid
)
insert tableA
SELECT *,其他字段
FROM OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ') as t
where not exists (
select 1 from tableA
where bid = t.bid
)
insert tableA
SELECT *,其他字段
FROM OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ') as t
where not exists (
select 1 from tableA
where bid = t.bid
)
SELECT *
INTO #t
FROM OPENROWSET('MSDAORA.1','hydata';'qyselect';'qy08select12','SELECT * FROM Hync31.V_QY_CKLSZ where 最后修改时间字段>=''2008-12-1''')
update tableA set
col1 = t.col1
,col2=t.col2
,...
from tableA,#t as t
where tableA.bid = t.bid
delete tableA
where 最后修改时间字段>='2008-12-1'
and not exists (
select 1 from #t as t
where tableA.bid = t.bid
)
insert tableA
SELECT *,其他字段
FROM #t as t
where not exists (
select 1 from tableA
where bid = t.bid
)
drop table #t