Connecting to Oracle from SQL Server

In: SQL Server


5 Jan 2009

Unfortunately, setting up a linked server to Oracle is not as easy as it should be. In fact, you’ll have to install some software on your server to make things work. I’ve put together a short guide on connecting to Oracle from SQL Server. The process doesn’t take very long but there are several hoops to jump through.

  1. Install Oracle Database 10g Client Release 2
    1. Install using the InstantClient option
  2. Install Oracle 10g Release 2 ODAC (64-bit, 32-bit)
    1. Select the Oracle Data Access Components option (not .NET!)
  3. Edit TNSNAMES.ora
    1. <install directory>Product10.2.0ClientnetworkADMINTNSNAMES.ora (i.e. C:OracleProduct10.2.0ClientnetworkADMINTNSNAMES.ora)
    2. There is a very specific format to the network configuration file. Here is an example to get you started (just copy & paste multiple entries if necessary):
      DMDEV =
        (DESCRIPTION =
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = SERVERNAME)(PORT = 1521))
          )
          (CONNECT_DATA =
            (SERVICE_NAME = FRIENDLYNAME)
          )
        )

      There are a couple of things you need to change:

      • HOST = SERVERNAME. The value SERVERNAME should be changed to reflect the actual address or hostname of the target system.
      • SERVICE_NAME = FRIENDLYNAME. FRIENDLYNAME is the name by which you refer to this actual connection.
  4. REBOOT!
  5. Configure provider in SQL Server
      OraOLEDB.Oracle Provider Menu Item

      OraOLEDB.Oracle Provider Menu Item

    1. Databases→DBName→Server Objects→Linked Servers→Providers→OraOLEDB.Oracle→Properties→Enable “Allow inprocess”
    2. Enable "Allow inprocess"

  6. Create a linked server to the Oracle Database
    1. General

      1. Linked Server: A name of your choosing which you will use when querying using four-part naming conventions.
      2. Provider: Oracle Provider for OLE DB
      3. Product Name: “Oracle” is fine here
      4. Data Source: This should match the HOST you defined in TNSNAMES.ora
      5. Create a Linked Server

        Create a Linked Server

    2. Security
      1. Select Be made using this security context and supply the remote login and password
  7. Query the linked server:
    SELECT TOP 10 * FROM LINKEDSERVERNAME..SYS.HELP
  • Share/Bookmark

7 Responses to Connecting to Oracle from SQL Server

Avatar

HOWTO: Setup SQL Server Linked Server to MySQL | Idea Excursion

February 25th, 2009 at 3:54 pm

[...] Server the ability to connect to a wide range of other systems. I’ve already written about how to connect Oracle and SQL Server. In this post, I’m going to go through the steps necessary to connect SQL Server and MySQL. [...]

Avatar

Adebimpe

April 15th, 2009 at 9:42 am

this is a really cool guide…it sorted out the problem i had with linked servers, forgot to tick the allow inprocess for the provider i created

Avatar

Jay

April 29th, 2009 at 4:08 pm

I’ve tried using both the Oracle provider OraOLEDB.Oracle and the SQL Provider MSDAORA.

Unable to get the OraOLEDB.Oracle provider to work at all. The MSDAORA provider return the error message ‘provider ran out of memory’ when trying to do an update to Oracle.

Suggestions?

Avatar

Taylor Gerring

April 29th, 2009 at 5:20 pm

The first things that come to mind to test are:

1. Do SELECT statements work?
2. How much data is the UPDATE statement modifying?

Avatar

Jason

April 20th, 2010 at 2:03 am

Hi,

I followed the instructions to the dot but still had the ORA 12154 error coming up. This was after I could successfully TNSping and valid the connection from Oracle Net Manager.

I finally did find a resolution after I put the TNSName in the Data source of the Linked Server instead of the Host name. I’m not sure how come but it worked. The TNSName in the above example would be DMDEV.

Avatar

zaid

July 8th, 2010 at 7:55 am

Hi,

I have installed sql server 2008 on a win server 2008 mashine, and I installed the Oracle Client.
my problem is the Provider “OraOLEDB.Oracle” is missing. and I cant make a link with the Oracle server.
can anyone helo thanks

Avatar

Mike

August 4th, 2010 at 7:03 am

Doh! The inprocess flag was killing me. Thanks.

Comment Form

  • Yushe » Blog Archive » Conectar SQL Server con MySql: [...] Disclaimer: El árticulo arriba no es mio, es solo una traducción parcial del árticulo aqui [...]
  • Nick: Here is an extensive how to on sharing folders with Windows 7. http://www.ilertech.com/2010/09/shar [...]
  • dushyant kayarkar: I attempted to update my password on Ubuntu today and encountered a strange error. I thought I’d d [...]
  • Prakash - Savvysoft Technologies: USE master GO -- To use named parameters: Add linked server in the source (Local machine - eg: Mac [...]
  • Mike: Doh! The inprocess flag was killing me. Thanks. [...]


This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.