"ORA-12154: TNS: cocould not resolve the connect identifier specified" error while creating a linked s

Source: Internet
Author: User
Tags oracle documentation

This is one of the most common errors while creating linked server to Oracle database. Today I will discuss the reason for this error and possible resolutions.

 

 

Full error message:

 

 

Ole db provider "MSDAORA" for linked server "LINKED_ORA" returned message "ORA-12154: TNS: cocould not resolve the connect identifier specified ".

 

 

Msg 7303, Level 16, State 1, Line 1

 

 

Cannot initialize the data source object of ole db provider "MSDAORA" for linked server "LINKED_ORA ".

 

 

First of all make sure you have reviewed the following Microsoft KB article that has a lot of good information on troubleshooting Oracle linked server issues.

 

 

How to set up and troubleshoot a linked server to an Oracle database in SQL Server

 

 

Http://support.microsoft.com/kb/280106

Also make sure you have installed Oracle Client on the SQL server. if the SQL server is 64 bit then we need to install 64 bit Oracle provider. you can also create linked server using Oracle ODBC driver together with Microsoft ole db provider for ODBC. once again on a 64 bit SQL server you need to install the 64-Bit OLEDB Provider for ODBC (MSDASQL) and 64 bit Oracle ODBC drivers. however 64-Bit OLEDB Provider for ODBC (MSDASQL) is already there in Windows Vista/Windows Server 2008 and later OS.

 

 

This particle error message is a very general error message and can happen for quite a number of reasons. For general understanding of the error, you can review oracle documentation like this http://ora-12154.ora-code.com/

 

 

In SQL Server Linked Server, it cocould indicate a few things (not limited )-

 

 

1. SQL Server (and oracle net libraries) is not able to get the TNS alias from tnsnames. ora file.

 

 

2. Something is wrong with the way the alias is created in the tnsnames. ora file (incorrect syntax)

 

 

3. TNS alias cocould not be resolved into a connect descriptor

 

 

Below is a list of things that you can try to resolve this issue.

 

 

1. Verify that the tnsnames. ora file has the alias and the service name that the customer is using.

 

 

TNS entry for the Oracle database

 

 

======================================

 

 

OracleDB_Dev =

 

 

(DESCRIPTION =

 

 

(ADDRESS_LIST =

 

 

(ADDRESS = (PROTOCOL = TCP) (HOST = server01.mydomain.com) (PORT = 1521 ))

 

 

)

 

 

(CONNECT_DATA =

 

 

(SERVICE_NAME = OracleDB)

 

 

(SERVER = DEDICATED)

 

 

)

 

 

)

 

 

 

In the above tnsnames. ora file Alias = OracleDB_Dev

 

 

Service Name: OracleDB (Actual Oracle service name [instance name in SQL])

 

 

2. check the sqlnet. ora file under 'admin' folder in Oracle home [Dir: \ app \ product \ 11.1.0 \ client_1 \ network \ Admin] and ensure that we have TNSNames in NAMES. DIRECTORY_PATH

 

 

NAMES. DIRECTORY_PATH = (TNSNAMES, ONAMES, HOSTNAME)

 

 

3. verify if you can connect to Oracle from the SQL server machine using tools installed with Oracle Client [For example "SQL Developer" or "SQL Plus"] with the same user id/password or TNS alias.

 

 

5. Check if the environment variable 'path' has the PATH for tnsnames. ora file specified.

 

 

Sample Value of Environment Variable PATH:

 

 

E: \ app \ product \ 11.1.0 \ client_1 \ bin; C: \ Program Files \ Business Objects \ Common \ 3.5 \ bin \ NOTES \; C: \ Program Files \ Business Objects \ Common \ 3.5 \ bin \ NOTES \ DATA \; % Systemroot % \ Microsoft. NET \ Framework \ v1.1.4322; % SystemRoot % \ system32; % SystemRoot % \ System32 \ Wbem; C: \ Program Files \ Dell \ SysMgt \ oma \ bin; C: \ Program Files \ Microsoft SQL Server \ 80 \ Tools \ BINN; C: \ Program Files \ Common Files \ Microsoft Shared \ web server extensions \ 60 \ TEMPLATE \ ADMIN \ 1033 \; c: \ Program Files \ Microsoft SQL Server \ 80 \ Tools \ Binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ DTS \ Binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ Tools \ binn \; C: \ Program Files \ Microsoft SQL Server \ 90 \ Tools \ Binn \ VSShell \ Common7 \ IDE \; C: \ Program Files \ Microsoft Visual Studio 8 \ Common7 \ IDE \ PrivateAssemblies \; C: \ Program Files \ Microsoft Network Monitor 3 \

 

 

Note: make sure that the path is a valid path and there is no space.

 

 

6. Check the value of the key "Oracle_Home" in the registry under HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE \ key_1_lient11g_home1 and verify that it has the right path for the Oracle home.

 

 

7. check for the registry key "TNS_ADMIN" at HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE. if it exists then make sure it has the right value as "Dir: \ app \ product \ 11.1.0 \ client_1 \ network \ admin ". if you don't see the key then create the key and set appropriate value as below.

 

 

Regedit-> HKEY_LOCAL_MACHINE-> Software-> Oracle-> RightClick NEW-> StringValue and name
It TNS_ADMIN and give the value "X: \ app \ product \ 11.1.0 \ client_1 \ network \ admin"

 

 

Note: This is not a must but in some cases this is what fixed the issue.

 

 

8. check if SQL server start up account has permission to the Oracle Home. also collect Process monitor log and check for "access denied ". process monitor log shocould show if we are able to find the tnsnames. ora file.

 

 

9. Make sure you don't have multiple Oracle homes or multiple Oracle clients installed. Check the "HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE \ ALL_HOMES \ HOME_COUNTER" key value.

 

 

10. Check if Oracle ole db provider is running InProcess. If 'yes' then try to run out-of-process and see if that resolves the issue.

 

 

Note: You can check and verify if ms ole db Provider for Oracle is running InProcess from the registry key at HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSSQLServer \ Providers \ MSDAORA

 

 

11. You can try collecting simultaneous Network trace from both SQL and Oracle servers and check if there are any communications between the two servers.

 

 

12. Try to connect to Oracle from the SQL server using the UDL. Use the same TNS name. If you get the same error that means the issue is not specific to SSMS or linked server.

 

 

Creating and processing ing Universal Data Link (. udl) Files

 

 

Http://msdn.microsoft.com/en-us/library/e38h511e (VS.71). aspx

13. try to specify all the information in the data source instead of using the TNS alias to connect to the Oracle database (this is a way to bypass tnsnames. ora file when connecting to Oracle ).

 

 

Sample Data Source:

 

 

Data Source = (DESCRIPTION = (CID = GTU_APP) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = server01.mydomain.com) (PORT = 1521 ))) (CONNECT_DATA = (SID = OracleDB) (SERVER = DEDICATED )));

 

 

Author: Hammad (MSFT) SQL Developer Engineer, Microsoft

Reviewed by: Azim (MSFT), SQL Developer Technical Lead, Microsoft

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.