我已经开始阅读表值参数的注释
这些TVP可以用作输入参数和输出参数吗?
让它们作为输出参数有意义吗?
我觉得可能会有一个TVP作为一个存储过程的输出,然后输入另一个存储过程--可能吗?
脚本的语法(调用第一个sproc,然后使用来自第一个输出的TVP调用第二个sproc )是我不确定的位。
编辑
抱歉,我的帖子混淆了--似乎最初的程序结果需要进入TVP --我认为TVP需要参与到这个sproc中。所以我所说的一个模型是--希望是TVP的有效使用.
CREATE TYPE myfirstTVP AS TABLE (id INT NOT NULL PRIMARY KEY);
GO --<<this sproc will find the ids (+ other fields) that need to be investigated
CREATE PROC test1 as
SELECT 1 UNION
SELECT 2 UNION
SELECT 3;
GO
GO --<<this sproc uses the found ids to do one aspect of the investigation
CREATE PROC test2
@t2 myfirstTVP READONLY
AS
SELECT id*2
FROM @t2;
GO
GO --<<this sproc uses the found ids to do another aspect of the investigation
CREATE PROC test3
@t4 myfirstTVP READONLY
AS
SELECT id*3
FROM @t4;
GO
--<<this is where the TVP is used and the sprocs are called
DECLARE @t3 myfirstTVP ;
INSERT INTO @t3
EXEC test1;
EXEC test2 @t3;
EXEC test3 @t3;发布于 2012-09-17 15:06:59
我不能百分之百肯定你想要实现什么,但在某种意义上你可以模仿“输出”参数的行为,
CREATE TYPE LIST_OF_INT AS TABLE (id int not null primary key);
GO
create procedure test1 as
begin
declare @t1 LIST_OF_INT;
insert into @t1 (id) values (1);
select * from @t1;
end;
GO
declare @t2 LIST_OF_INT ;
insert into @t2
EXEC test1;
select * from @t2;发布于 2012-09-17 14:58:54
我想你漏掉了你引用的MSDN链接中的这一点。
表值参数必须作为输入的READONLY参数传递给Transact-SQL例程。
https://stackoverflow.com/questions/12461913
复制相似问题