How to join linked server table and sql server table while using openquery

后端 未结 1 1610
南方客
南方客 2021-01-05 12:47

I use openquery syntax to read the data from a linked server.

SELECT * FROM OPENQUERY(LinkServer, \'SELECT * FROM Product\')

I want to joi

相关标签:
1条回答
  • 2021-01-05 13:48

    I don't have the ability to test this, but it does offer an opportunity to bypass the #tempTable option by directly joining to the remote server (if such connection is possible)

    SELECT  A.* 
      FROM  OPENQUERY(TREPO, 'SELECT ID, Name FROM Products') A
     INNER 
      JOIN  ORDERED_PRODUCTS B
        ON  A.ID = B.ID
    

    Here is a link to some information about linked server queries, and some pitfalls that can be encountered: http://sqlblog.com/blogs/linchi_shea/archive/2009/11/06/bad-database-practices-abusing-linked-servers.aspx

    0 讨论(0)
提交回复
热议问题