This tip was originally published on SearchSQLServer.com.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Working with both Oracle and SQL Server databases presents a variety of challenges -- precisely why we've compiled this collection of short lessons by Kevin Kline, our resident Monitoring/Administration expert. If you have questions about working with Oracle and SQL Server, submit them today.
Your Instructor: Kevin Kline, Monitoring/Administration Expert
Kline is director of SQL Server Solutions at Quest Software and president of the international Professional Association for SQL Server (PASS). Here he addresses the following topics:
Excecuting an Oracle stored procedure on SQL Server
Question: Is it possible to execute an Oracle stored procedure on SQL Server? If so, how?
Kline: Oracle uses its own dialect of SQL called PL/SQL (procedural language extension to Structured Query Language), while SQL Server uses T-SQL (Transact-SQL). The two have very different rules about variables, parameters, conditional processing, error handling and so forth. So unless the Oracle stored procedure contains only ANSI SQL statements, it won't work on SQL Server. However, Microsoft recently introduced a new tool that aids in the migration process from Oracle to SQL Server. You should investigate the SQL Server Migration Assistant. You should also note that moving from Oracle to SQL Server is not considered a simple point-n-click process. It usually involves a healthy dose of planning, analysis and good ol' fashion elbow grease.
Connecting an Oracle application to SQL Server
Question: I am currently working on a project with Oracle9i Forms at the front end and Microsoft SQL Server at the back end. What steps should I take to connect an Oracle9i Forms application with a SQL Server database?
Kline: I can't think of an easy way off of the top of my head. There's the Oracle Transparent Gateway. But that is certainly not an easy approach. There are also a few tools available using Oracle's Migration Workbench. You may also be able to connect using a JDBC driver. Check out Microsoft's JDBC driver for SQL Server. You can also find a list of JDBC drivers at DevX.com.
Importing data from other databases to SQL Server
Question: Can a stored procedure be used to import data from other types of databases and text files to SQL Server?
Kline: Absolutely! I've written many stored procedures to import data from other servers, usually Oracle and Access as well as from text files. When importing data from other servers, you'll have an easier time if you set up the source server as a Linked Server (see SQL Server Books Online for more details).
Once you've set up the Linked Server, you can write SQL statements directly against the Linked Server. For example, you could write the statement INSERT INTO local_table…SELECT col1, col2,… FROM linked_server.db1.dbo.foo.
When importing data from text files, simply use the BULK INSERT statement or, my preference, call the BCP command line utility using XP_CMDSHELL within the stored procedure. It takes a little work to get the exact XP_CMDSHELL string correct. All you have to do is encapsulate the BCP command-line string within a parameter for XP_CMDSHELL extended stored procedure.