在openquery中命名表

时间:2015-09-29 12:59:58

标签: sql sql-server-2012

这很好,正如我所料:

SELECT * FROM Openquery(RETAIL_PROD_UK, 'select LOAN_STATUS FROM lloanall')

但为什么我不能这样做呢?是不是可以在openquerys中使用连接?

SELECT * FROM Openquery(RETAIL_PROD_UK, 'select LOAN_STATUS FROM lloanall As l')
  

Msg 7321,Level 16,State 2,Line 1准备时出错   查询"选择LOAN_STATUS FROM lloanall作为l"执行   针对OLE DB提供程序" MSDASQL"对于链接服务器" RETAIL_PROD_UK"。

1 个答案:

答案 0 :(得分:1)

您可以尝试这样:

SELECT * FROM Openquery(RETAIL_PROD_UK, 'select LOAN_STATUS FROM lloanall') As l

现在你可以按照这样的方式进行加入:

SELECT * FROM Openquery(RETAIL_PROD_UK, 'select LOAN_STATUS FROM lloanall') As l
JOIN someTable s ON s.id = l.id