Home > Oracle Tips > Oracle Database Administrator > Oracle and SQL Server: BFF?
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Oracle and SQL Server: BFF?


Hope Foley
10.04.2007
Rating: -4.08- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


BFF (best friends forever)? Not quite. More like two kids on the DBMS playground that would just as soon throw spitballs at each other as play nice together. However, with the release of SQL Server 2005, it has become easier than ever for SQL Server to coexist with rival Oracle.

In this article, I provide an overview of some of the new and old ways to successfully exchange data between Oracle and SQL Server 2005 instances. The sharing of data between the two is becoming a very common process, in part due to the licensing of the reporting tool for SQL Server. SQL Server Reporting Services (SSRS) is a free component with a valid license of SQL Server (although you must have per-processor licensing to use Internet reporting). In many cases, data is ported over solely to run reports. Whatever the reason, with more and more database shops using both products, the need is greater than ever to share data between the two unlikely playmates.

There are three common ways to get data from Oracle into SQL Server:

  1. SQL Server Integration Services (SSIS) -- pump data from Oracle into SQL Server databases.
  2. Replication -- set up Oracle in SQL Server to be a replication publisher.
  3. Linked server -- run queries directly from SQL Server to Oracle databases after linking.

SQL Server Integration Services

SSIS is a data integration tool that is included free with a license of SQL Server (except for the Express version). It replaces what was previously known as Data Transformation Services (DTS). Essentially, SSIS is a very powerful enterprise-class extract, transform and load (ETL) tool. It allows you to move data from Oracle or other sources into SQL Server in a few simple steps, although additional steps can be added to cleanse the data prior to loading it into SQL Server. The Oracle client is a prerequisite installation on the server where you're going to import the data or the location where you will be running your SSIS package. In addition, a valid userid/password for the Oracle database is required.

You are now ready to begin setting up your SSIS package:

In SQL Server, open Business Intelligence Development Studio (BIDS) and create an Integration Services project.

Move a data flow task into the control flow design pane. Double-click on this task and it will bring you into the data flow pane. Here you will create the tasks to move your Oracle data.

Move an OLE DB source task into the design pane. Double-click it and configure a connection to your Oracle database (Figure 1). You will supply either the table or view you want to copy, or you can supply a SQL command to pull portions of the data. You can then add any cleansing tasks needed to the data or directly copy it into SQL Server. The only thing needed now is a destination for your data. You can put it in numerous formats or into a SQL Server database.

Fig 1
Figure 1. Enter your Oracle connection information in OLE DB Source

Move an OLE DB Destination task into the pane, connect the source task to the destination task, and then configure the destination. You now have an SSIS package to copy data from Oracle (Figure 2). It can be deployed and scheduled to run at regular intervals in an SQL Agent job.

Fig 2
Figure 2. What the SSIS package will look like from Data Flow pane

Replication

Replication has been in place within SQL Server since version 6.0. New in SQL Server 2005 is the ability to set up an Oracle publisher (with Oracle versions 8.0.5 and higher). Replication, in a nutshell, is a method to copy data and objects between servers and keep them synchronized. A media metaphor is used: First, the data and objects to be copied are contained in an article. A publication can then contain one or more articles. Next, there is a subscriber, which is an instance of SQL Server that can access that publication. The subscriber requests the publication through a subscription. Finally, there is also a distributor, which handles the passing of the subscription from the publisher to the subscribers.

There are three types of replication that can occur in SQL Server: merge, transactional and snapshot. Merge replication allows for updates to occur at the subscribers and publisher; the data is then synchronized among all. This can create conflicts, but there are numerous methods to handle those conflicts. Transactional replication only allows for changes at the publisher. The incremental changes are then propagated down to the subscribers in near real time. Snapshot replication copies all data from the publication to the subscribers at specified intervals and does not monitor changes. Snapshot works well only when you need to copy small amounts of data infrequently and when high latency is not an issue. Replicating with an Oracle database only allows for snapshot and transactional replication.

Here are the steps to set up an Oracle publisher in SQL Server:

  1. Ensure that you have a separate distributor set up to aid in the replication.
  2. Create a replication administrative user within the Oracle database. SQL Server provides a sample script you can use to create the user in \\Program Files\Microsoft SQL Server\\MSSQL\Install\oracleadmin.sql. The user that runs the script on the Oracle database must have admin privileges.
  3. Grant select permissions to the replication admin user implicitly (i.e., not through a role).
  4. Install the latest Oracle client on the distributor, stop/start the SQL instance and verify connectivity.
  5. Set up the Oracle database as a publisher, as well as the publication or what data you will exchange. You can do this via Wizards from the distributor (right-click local publications from within SQL Server Management Studio and select "Add Oracle Publication").

Linked servers

Linked servers are a third method to access Oracle information with SQL Server. Once linked servers are set up, you have the ability to run distributed queries against Oracle via SQL Server. To use this method, you must have an Oracle client installed on your SQL Server machine and a valid Oracle user/password. Setting up the linked server is easy; simply run the following command:

EXEC sp_addlinkedserver
   @server = 'Name of Linked server',
   @srvproduct = 'Oracle',
   @provider = 'MSDAORA',
   @datasrc = 'Data Source Name'
GO

Then you must add the login for the linked server:

EXEC sp_addlinkedsrvlogin 
   @rmtsrvname = 'Name of Linked Server', 
   @useself = 'false', 
   @locallogin = 'Local SQL login', 
   @rmtuser = 'Oracle User', 
   @rmtpassword = 'Oracle Password' 

You then can query the Oracle database using full syntax. For example:

SELECT * FROM <Name of Linked Server>..<Oracle Schema>.<Table Name>

Conclusion

While Oracle and SQL Server may never be BFF, you can use these methods to access Oracle data from within SQL Server. Your data comes together, your customers are happy, and the world is a better place. And besides, if these two old rivals did become best friends, what would Oracle and SQL Server DBAs have to argue about?

About the author

Hope Foley is a SQL Server DBA and analyst for Perpetual Technologies Inc. (PTI) in Indianapolis. PTI provides mission-critical database and information systems support for SQL Server and Oracle environments nationwide. PTI experts plan, design, develop, deploy and manage database environments and applications to achieve the best combination of tools and services for each client need. As a respected member of the PTI team, Hope brings seven years of IT experience to PTI and is responsible for database design, administration and support, data warehousing and data mining, and custom database solutions for business enterprises across the United States.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

Oracle data and application integration
Oracle to acquire application service management firm
Oracle updates its enterprise performance management system, details Hyperion integration
Podcast: Oracle outlines AIA vision
Oracle's 10 steps to get to Fusion rely on Oracle investments
Oracle Fusion Middleware: Top five headlines
Oracle adds Data Integration Suite to middleware family
Oracle-BEA deal means tough choices for middleware buyers
Oracle to buy BEA Systems
Oracle adds Enterprise 2.0 to Fusion Middleware 11g
Oracle scoffs at BEA's buyout proposal

Oracle database export, import and migration
Oracle as data integrator
Importing from Oracle 8i to Oracle 10g
Export schemas of users of database
Exp/imp for complex cross-platform migration and upgrade
How to export data by date in Oracle
Large data migration from XML database to Oracle 10g
Data exchange between Oracle 10g and 8i databases
IMP-00017 error message with Oracle import
Transparent Gateways between Oracle database and DB2
LOB tables missing with exp/imp move of schema

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Oracle Development Solutions - SQL, J2EE, XML, SOA
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts