Can't create stored procedure with table output parameter

此生再无相见时 提交于 2019-11-27 15:41:34

Table parameters are readonly. You cannot select into them. Use Table-Valued Parameters:

Table-valued parameters must be passed as input READONLY parameters to Transact-SQL routines. You cannot perform DML operations such as UPDATE, DELETE, or INSERT on a table-valued parameter in the body of a routine.

And Table-Valued Parameters:

You cannot return data in a table-valued parameter. Table-valued parameters are input-only; the OUTPUT keyword is not supported.

Read Arrays and Lists in SQL Server for a comprehensive discussion on alternatives.

Rodders

As Remus states, you can't do that exactly but you could accomplish what you want to achieve by using a User-Defined Function instead: tsql returning a table from a function or store procedure

Which will return your data in a table however I believe you will need to define the table in the Function and not define it as a type

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