答案 0 :(得分:4)
答案 1 :(得分:1)
感谢。我的这个时刻来自这篇文章。没有意识到输出参数在执行时也需要使用“输出”标识符进行限定,而不仅仅是在程序中!
这是我的同伴sql server noobs的测试工作。我正在使用sqlcmd和sql server 2005。
存储过程:
/* :r procTest.sql */
if exists (select name from sysobjects where name="procTest" and type="P")
drop procedure procTest;
go
create procedure procTest
/* Test stored procedure elements. */
(@i_pt_varchar varchar(20),
@o_pt_varchar varchar(20) output)
as
begin
print "procTest";
set @o_pt_varchar = "string coming out";
print "@i_pt_varchar " + @i_pt_varchar;
print "@o_pt_varchar " + @o_pt_varchar;
return (0);
end
go
测试电话:
/* :r procTest.test.sql */
declare @returnFlag int;
declare @i_varchar varchar(20);
declare @o_varchar varchar(20);
set @i_varchar = "string going in";
set @o_varchar = null;
execute @returnFlag = procTest @i_varchar, @o_varchar output
print "@returnFlag " + cast(@returnFlag as varchar(20));
print "after call";
print "@i_varchar " + @i_varchar;
print "@o_varchar " + @o_varchar;
go