The metadata could not be determined because every code path results in an error; see previous errors for some of these

别来无恙 提交于 2019-12-10 19:46:39

问题


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]')

I get the following error message:

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.

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 and #MyTempTable are not real names.

What could cause this error? Any help would be appreciated.

Thanks


回答1:


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));')


来源:https://stackoverflow.com/questions/35951765/the-metadata-could-not-be-determined-because-every-code-path-results-in-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!