SQL Server - OPENQUERY

Mar*_*iff 4 sql sql-server-2005 sql-server-2008

我正在使用一个在SQL Server 2005上运行良好的Openquey,我有一台服务器是SQL Server 2008,但这不起作用.

如果我运行以下内容:

SELECT * 
FROM OPENQUERY([Manchester], 
      '[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'', 
      ''10/10/2009''')
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Cannot process the object "[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance '10/01/2009', '10/10/2009'". 
The OLE DB provider "SQLNCLI" for linked server "Manchester" indicates that either the object has no columns or the current user does not have permissions on that object.
Run Code Online (Sandbox Code Playgroud)

如果我只是运行:

[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance '10/01/2009', '10/10/2009'
Run Code Online (Sandbox Code Playgroud)

它工作正常.2008年发生了什么变化?

它的作用是从openquery获取数据并插入到我的临时表中:

INSERT #TempHandheldPerformance SELECT * FROM OPENQUERY([Manchester], '[Manchester].PilotWebApp.DBO.rsp_HandheldPerformance ''10/01/2009'', ''10/10/2009''')
Run Code Online (Sandbox Code Playgroud)

jjc*_*hiw 8

即使是2009年的问题,我在2012年也遇到了同样的问题!并且有点难以找到答案......无论如何,在执行SP之前只使用了SET NOCOUNT ON

如果曼彻斯特是LinkedServer,那么SET NOCOUNT ON的示例代码应该是

SELECT * 
FROM OPENQUERY([Manchester], 
      'SET NOCOUNT ON; EXEC [PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'', 
      ''10/10/2009''')
Run Code Online (Sandbox Code Playgroud)

并填写我做的临时表

SELECT *
INTO #temptable
FROM OPENQUERY([Manchester], 
          'SET NOCOUNT ON; EXEC [PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'', 
          ''10/10/2009''')
Run Code Online (Sandbox Code Playgroud)

/sf/answers/157304031/