When I tried to execute query I got the below error.
SELECT *
FROM OPENQUERY([TESTORACLE], 'select * from TESTTABLE')
Cannot initialize the data source object of OLE DB provider "MSDASQL"
for linked server "TESTORACLE".
I have created DSN and used below query to create linked server.
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'TESTORACLE'
,@useself = 'False'
,@locallogin = NULL
,@rmtuser = 'USERNAME'
,@rmtpassword = 'PASSWORD';
EXEC sp_addlinkedserver
@server = 'TESTORACLE'
,@srvproduct = 'ORCLELINK'
,@provider = 'MSDASQL'
,@datasrc = 'ORCLELINK'
After that I tested the linked server and it worked fine.
When I execute a query it throws access denied exception so I enable Allow In process to the provider.
After that it throws above error and the test connection also not works.
Not sure why the connection fails when I enable Allow in process.
Please help me to resolve the error.
Thanks,
Best Answer
First, install the correct Oracle drivers. You want the latest version of the Oracle Data Access Components (ODAC), and you want the XCopy deployment. They are available here: 64-bit Oracle Data Access Components (ODAC) Downloads http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html
One you download and unzip this into a folder run the following command from that folder:
Then you need to add two folders to your system path:
Then you must reboot for the system path change to be visible by services like
SQL Server
.After reboot you're ready to create and test the linked server. First configure the Oracle OleDB provider to run inside the SQL Server process, and configure it to accept parameters.
Then create the linked server definition. Instead of a TNSNames alias, use an EZConnect identifier. Here I'm specifying an IP address and a SID to connecto to an Oracle Express instance running on a VM:
Now you're ready to test. You configured the linked server for 'rpc out' so we can send a simple passthrough query to test connectivity:
That's it.