While configuring Linked server to oracle database from SQL server, faced following error,
Error: “ORA-12504: TNS: listener was not given the SERVICE_NAME in CONNECT_DATA” (Microsoft SQL Server Error: 7303)
I did following validation checks to ensure things are in place:
- Tnsnames.ora – validated that SID is present in tnsnames.ora file which is generally located in C:\Oracle\product\11.2.0\client_1\network\admin\ folder
-
Validate syntax of connection string, it should be in below format,
ORA123 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = abcd123.domain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora123)
)
)
-
Validated that linked server is set as per tnsnames.ora entry,
-
Validated that under providers, OraOLEDB.Oracle setting is for “Allow inprocess”
-
Done tnsping which came out OK,
After validating all above, still the error was same.
After reviewing some blogs, seems fix was to update the “Provider String” with entry as below, once that is done, it fixed the issue,
Use provider string as below,
“data source=//ora123:1521/abcd123.domain.com”
Alternatively, user name and password can also be supplied but it is not recommended,
“userid=test123;password=ab$!@$k12098;data source=//ora123:1521/abcd123.domain.com”
After creating linked server, test using below query,
select
*
from
openquery(ora123,
‘select * from v$database’)
Hope this helps someone in same situation.
Useful references:
Install and setup linked server for oracle
http://www.ideaexcursion.com/2009/01/05/connecting-to-oracle-from-sql-server/
Listener issues:
https://community.oracle.com/thread/367507?start=0&tstart=0
http://docs.oracle.com/cd/B19306_01/win.102/b14307/featConnecting.htm#sthref114
Query Oracle DB using linked server:
http://stackoverflow.com/questions/11309762/querying-an-oracle-database-from-sql-server
https://dbbulletin.wordpress.com/2010/06/30/using-powershell-for-oracle-dba-scripts/
