由于每个代码路径都会导致错误,因此无法确定元数据.请参阅先前的错误 [英] The metadata could not be determined because every code path results in an error; see previous errors for some of these
问题描述
我正在从SQL Server 2005迁移到SQL Server 2014,并且其中一个查询在SQL Server 2014中停止工作:
I am migrating from SQL Server 2005 to SQL Server 2014 and one of the queries stopped working in SQL Server 2014:
select *
from openrowset ('SQLOLEDB','Server=(local);TRUSTED_CONNECTION=YES;',' exec [MyDatabase].[dbo].[MyTable]')
我收到以下错误消息:
消息11529,级别16,状态1,过程sp_describe_first_result_set, 第1行
由于每个代码路径都会导致错误,因此无法确定元数据.请参阅先前的错误.
Msg 11529, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1
The metadata could not be determined because every code path results in an error; see previous errors for some of these.
消息4902,级别16,状态1,过程sp_describe_first_result_set,第1行
无法找到对象"#MyTempTable",因为它不存在或您
没有权限.
Msg 4902, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1
Cannot find the object "#MyTempTable" because it does not exist or you
do not have permissions.
dbo.MyTable
和#MyTempTable
不是真实姓名.
什么可能导致此错误?任何帮助将不胜感激.
What could cause this error? Any help would be appreciated.
谢谢
推荐答案
从SQL Server 2012开始,您需要使用WITH RESULT SETS
显式描述结果集:
From SQL Server 2012 onwards, you need to use WITH RESULT SETS
to explicitly describe the result set:
EXEC('exec [MyDatabase].[dbo].[StoredProcedure] WITH RESULT SETS (( val SMALLINT));')
这篇关于由于每个代码路径都会导致错误,因此无法确定元数据.请参阅先前的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!