Use ms SQL to implement distributed query of heterogeneous databases using t-SQL code (original)

Source: Internet
Author: User

/* Use ms SQL to implement the T-SQL code for Distributed Query of heterogeneous databases */

Exec sp_addrole server 'Ms _ SQL ', '', 'sqloledb', '2017. 18.9.20'
Exec sp_add1_srvlogin 'Ms _ SQL ', 'false', null, 'sa', 'capec '/* Create a sqlserver remote connection to the sqlserver database */

Exec sp_addmediaserver 'ora ', 'oracle', 'msdaora ', 'Hj'
Exec sp_add1_srvlogin 'ora ', false, 'sa', 'ccense ',' ****** '/* Create a sqlserver remote connection to the Oracle database */

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 Distributed Query between the local SQL Server and 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)/* Distributed Query of remote ms SQL and Oracle */

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.