Query an Oracle Linked Server table from SQL Server

I have an Oracle Linked Table setup in my SQL Server database.  In order to query it’s internal tables (without needing to use OpenQuery), I use the following syntax:

[SQL]

SELECT * FROM [LinkedServerName]..[Schema].[TableName]

[/SQL]

Because the query is executed within SQL Server, you can use SQL Server-specific functions such as TOP, GetDate(), etc.  In order to pass a query directly to the Oracle table, using Oracle-specific functions/variables (TO_CHAR, SYSDATE, etc), and return the related dataset, use OpenQuery.

Leave a comment