Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 OpenQuery Question

Author  Topic 

joe8079
Posting Yak Master

127 Posts

Posted - 2012-09-04 : 17:32:03
I have a connection to an oracle server where I have a table on the linked server that I need to join to a SQL server table. Is this possible? Each table holds around 4.5 Million records and I thought about dumping the values into temp tables and doing the joins there, but that is not very efficent for what I'm trying to do.
Basically, I would like to use the SQL server table within openQuery. Is this possible?


-- linked server code
select * from openquery(linkedserver,
'select column1, column2, column3 from linkedServerTable')

--sql server code
select column1, column2 from sqlServerTable



robvolk
Most Valuable Yak

15732 Posts

Posted - 2012-09-04 : 17:46:50
Joining via OPENQUERY or 4-part names across linked servers is always going to provide the worst performance possible. The ODBC/OLE DB driver will ultimately translate a JOIN into a cursor against the linked server. It's better to pull only the data you need from the linked server and put it into a temp (or regular) table on SQL Server, then JOIN to that. Eliminate any columns you don't need and use a WHERE clause in OPENQUERY to eliminate rows you don't need.
Go to Top of Page
   

- Advertisement -