title: How to join linked server table and sql server table while using openquery
body: <p>I use openquery syntax to read the data from a linked server. </p>
  
  <pre><code>SELECT * FROM OPENQUERY(LinkServer, 'SELECT * FROM Product')
  </code></pre>
  
  <p>I want to join this link server table with an Sql server table to get my final results. For now I do it by, having a temp table.</p>
  
  <pre><code>SELECT * 
  INTO #Temp_Products
  FROM OPENQUERY(TREPO, 'SELECT ID, Name FROM Products')
  
  SELECT * FROM #TEMP_PRODUCTS A
  INNER JOIN ORDERED_PRODUCTS B
  ON A.ID = B.ID
  </code></pre>
  
  <p>But as the link server product table contains huge records, it takes time to get filled into the temp table. So I think instead of pulling all product information, If I join both the tables before hand, it could increase the performance. </p>
  
  <p>Can this be done.? Can someone help?</p>