gpt4 book ai didi

SQL Server - OPENQUERY

转载 作者:行者123 更新时间:2023-12-04 22:01:02 27 4
gpt4 key购买 nike

我正在使用在 SQL Server 2005 上运行良好的 Openquey,我有 1 台服务器是 SQL Server 2008,但它无法正常工作。

如果我运行以下命令:

SELECT * 
FROM OPENQUERY([Manchester],
'[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'',
''10/10/2009''')

我收到此错误:
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.

如果我只是运行:
[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance '10/01/2009', '10/10/2009'

它工作正常。 2008 年有什么变化吗?

它所做的是从 openquery 获取数据并插入到我的临时表中:
INSERT #TempHandheldPerformance SELECT * FROM OPENQUERY([Manchester], '[Manchester].PilotWebApp.DBO.rsp_HandheldPerformance ''10/01/2009'', ''10/10/2009''')

最佳答案

即使是 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''')

并填充我做的临时表
SELECT *
INTO #temptable
FROM OPENQUERY([Manchester],
'SET NOCOUNT ON; EXEC [PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'',
''10/10/2009''')

https://stackoverflow.com/a/2247200/181766

关于SQL Server - OPENQUERY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1625055/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com