简体   繁体   English

SQL Server OpenQuery的存储过程失败

[英]SQL Server OpenQuery Fails with stored procedure

I've got a stored procedure which takes two parameters. 我有一个带有两个参数的存储过程。 I'm trying to use OpenQuery in SQL Server to join on the result set of my stored procedure dbo.TwoDrugs . 我试图在SQL Server中使用OpenQuery来加入存储过程dbo.TwoDrugs的结果集。 The SQL Server is only a local machine with no one else having access. SQL Server只是一台本地计算机,没有其他人可以访问。 I'm trying to do 我正在努力

select * 
from OpenQuery (AHCTW208D02,'exec [i 3 sci study].dbo.TwoDrugs ''X'',''Y''')

and I get the error 我得到了错误

Msg 7357, Level 16, State 2, Line 1 Msg 7357,第16级,州2,第1行

Cannot process the object "exec [i 3 sci study].dbo.TwoDrugs 'X','Y'". 无法处理对象“ exec [i 3 sci study] .dbo.TwoDrugs'X','Y'”。 The OLE DB provider "SQLNCLI10" for linked server "AHCTW208D02" indicates that either the object has no columns or the current user does not have permissions on that object. 链接服务器“ AHCTW208D02”的OLE DB提供程序“ SQLNCLI10”指示该对象没有列或当前用户对该对象没有权限。

I can't think of a reason why I wouldn't have permission (since I created the stored procedure), and I configured the server for data access. 我想不出没有权限的原因(因为我创建了存储过程),因此我将服务器配置为可进行数据访问。

When I run the stored procedure it does in fact return a result set. 当我运行存储过程时,它实际上会返回结果集。 Any ideas on what might be the problem with this? 关于这可能是什么问题的任何想法?

OPENQUERY cannot be used to execute extended stored procedures on a linked server. OPENQUERY不能用于在链接服务器上执行扩展存储过程 However, an extended stored procedure can be executed on a linked server by using a four-part name. 但是,可以使用四部分名称在链接服务器上执行扩展存储过程。 For example: 例如:

exec AHCTW208D02.[i 3 sci study].dbo.TwoDrugs 'X','Y';

please read Remaks 请阅读Remaks

Reference: http://msdn.microsoft.com/en-us/library/ms188427.aspx 参考: http : //msdn.microsoft.com/en-us/library/ms188427.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM