A thought of SQL Server and Oracle data Mutual guidance--sql server linked servers

Source: Internet
Author: User
Tags management studio sql server management sql server management studio

Idea: You can remotely query the table of an Oracle database by adding a linked server to the SQL Server database
Environment preparation, install the SQL Server database, install the Oracle driver, configure the Oracle connection in the configured Tnsname file, I use the SQL server2008 r2,oracle11g test, Provider adoption of the OraOLEDB.Oracle (many articles on the web said this could not be successful, to choose Microsoft OLE DB privider for Oracle, I chose this configuration is successful, it is estimated that there can be no more than two, if there are two, SQL Server default with Microsoft's)

The Tnsmae configuration is as follows:

Orcl11 = (DESCRIPTION = (Address_list = (ADDRESS = (PROTOCOL = TCP) (HOST = WILSONPC3) (PORT = 1521))) (Connect_data = (service_ NAME = orcl11)))

  

First, make sure that the SQL Server machine is connected to Oracle via Sqlplus

Add Oracle access to the SQL Server linked server named Oracl

Querying the Oracle database remotely in SQL Server Management Studio

SELECT * FROM OPENQUERY (oracl, ' select Empno,ename,job,mgr,hiredate,sal,comm,deptno from emp ') Ainner join EMP Bon a.empno =b.empnoand b.empno=7369

  

The OPENQUERY result is equivalent to returning a remote table object that can be used as a link to the SQL statement, or an update delete operation on the Oracle data, for example, the following code inserts a remote Oralcle database:

Insert INTO OPENQUERY (Oracl, ' select Empno,ename,job,mgr,hiredate,sal,comm,deptno from emp ') SELECT [empno]+1000,[ Ename],[job],[mgr],[hiredate],[sal],[comm],[deptno]from EMP

  


Delete operation:

Delete from OPENQUERY (Oracl, ' select Empno,ename,job,mgr,hiredate,sal,comm,deptno from emp ') where empno= ' 7369 '

With the above methods of operation, SQL Server and Oracle data Mutual guidance has a basic idea.

A thought of SQL Server and Oracle data Mutual guidance--sql server linked servers

Related Article

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.