Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking Oracle with SQL Server

I'm trying to link SQL Server 2005 to an Oracle 10g database. I've installed the Oracle client on the SQL server and validated that I can connect to the Oracle database using both tnsping and sqlplus. When I try to run a query in SQL Server I get the following:

OLE DB provider "OraOLEDB.Oracle" for linked server "ORA_CSSA2APD" returned message "ORA-12154: TNS:could not resolve the connect identifier specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "ORA_CSSA2APD".

Any ideas? I've tried both of the following queries with no luck:

select * from openquery(ORA_CSSA2APD, 'select count(rowid) from eservice_op.agent')

select count(rowid) from ORA_CSSA2APD..eservice_op.agent

like image 992
bokoxev Avatar asked Aug 09 '10 22:08

bokoxev


People also ask

Can you link an Oracle database to SQL Server?

Follow the steps below to link your Oracle to SQL Server right from the Object Explorer pane: On the Management Studio, choose your SQL Server Instance. Click on the Server Objects from the Object Explorer pane and select Linked Servers, then New Linked Server.

How do I create a linked server between SQL and Oracle?

Oracle provider and enable Allow inprocess. To create the Linked Server, connect the SQL Server engine from SQL Server Management Studio and navigate to Server Objects. Expand the Server Objects section, and you will find Linked Servers. Right-click on Linked Servers to create the New Linked Server.

Can you use SQL with Oracle?

SQL for Accessing, Defining, and Maintaining Data Oracle SQL provides an easy, elegant, performant architecture for accessing, defining, and maintaining data. Use SQL with Oracle and PHP, Java, Python, . NET, Hadoop, Node.

What is Oracle database gateway for SQL Server?

Oracle Database Gateways provide the ability to transparently access data residing in a non-Oracle system from an Oracle environment. The following sections briefly cover Heterogeneous Services, the technology that the Oracle Database Gateway for SQL Server is based on.


2 Answers

This issue happened to me, as well, but only with certain Windows user accounts. A combination of enabling the "Allow inprocess" provider option for the OraOLEDB.Oracle provide (SSMS > Server Objects > Linked Servers > Provides > OraOLEDB.Oracle), restarting the SQL Server Windows service and lastly adjusting the permissions on the TNSNAMES.ora file directly.

like image 59
KirstieBallance Avatar answered Oct 21 '22 21:10

KirstieBallance


I suspect an environment setting. That is, your session is picking up the TNSNAMES.ORA file but the session underlying SQL Server is not. I'd check were ORACLE_HOME and, possibly, TNS_ADMIN are being set and pointing to.

Are you able to use the easy connect syntax for the database with the SQL Server connection .

IE replace ORA_CSSA2APD with hostname:1521/service_name

like image 40
Gary Myers Avatar answered Oct 21 '22 22:10

Gary Myers