/*利用ms sql实现异构数据库的分布式查询的t-sql代码*/
exec sp_addlinkedserver 'ms_sql','','sqloledb','172.18.9.20'
exec sp_addlinkedsrvlogin 'ms_sql','false',null,'sa','capec' /*创建一个sqlserver对sqlserver的数据库远程链接*/
exec sp_addlinkedserver 'ora', 'oracle', 'msdaora', 'hj'
exec sp_addlinkedsrvlogin 'ora', false, 'sa', 'ccense', '******' /*创建一个sqlserver对oracle的数据库远程链接*/
select v_rec.customerid,rec.opdt,rec.collectdt,rec.upload,rec.opcount rec_opcount,v_rec.opcount as v_rec_opcount
from ora..ccense.rec_cust_acc v_rec inner join
rec_cust_acc rec on v_rec.customerid = rec.customerid and
v_rec.opcount = rec.opcount
where (rec.upload = 0) /*ms sql本机与oracle的分布式查询*/
select v_rec.customerid,rec.opdt,rec.collectdt,rec.upload,rec.opcount rec_opcount,v_rec.opcount as v_rec_opcount
from ora..ccense.rec_cust_acc v_rec inner join
ms_sql.localcost.dbo.rec_cust_acc rec on v_rec.customerid = rec.customerid and
v_rec.opcount = rec.opcount
where (rec.upload = 0) /*远程ms sql与oracle的分布式查询*/
新闻热点
疑难解答