T-SQL中具有表参数的存储过程 [英] Stored Procedure that has table argument in T-SQL

查看:184
本文介绍了T-SQL中具有表参数的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将表变量传递到以表参数作为输出的过程中, 但不是只读的!我希望能够在PROC中修改该参数. 这可能吗? 如果不可能的话,还有另一种方法吗?

I want to pass a table variable into a procedure that has table argument as output, but not as read only! I want to be able to modify that argument inside the PROC. Is this possible? If it's not possible, is there another way to do this?

谢谢!

推荐答案

您必须将表值参数复制到表变量或临时表中

You'd have to copy the table valued parameter into a table variable or temp table

CREATE PROC DoStuff
    @tvp SomeTableType READONLY
AS
..
SELECT * INTO #LocalCopy FROM @tvp; -- take local copy
...
DoStuff -- do processing on the input
...
SELECT ... FROM LocalCopy;  --return results to client
GO

注释后,不能将表值参数声明为OUTPUT.从创建程序

After comment, a table valued parameter can not be declared OUTPUT. From CREATE PROC

不能将表值数据类型指定为过程的OUTPUT参数.

A table-value data type cannot be specified as an OUTPUT parameter of a procedure.

这篇关于T-SQL中具有表参数的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆