Output Parameter Not Returned
Why does this script return a pair of nulls? I'm using SQL Server 2008, script run in MSSMS.
CREATE PROCEDURE proc_Test
(
@Input int,
@Out1 int OUTPUT,
@Out2 varchar(10) OUTPUT
)
AS
BEGIN
SET NOCOUNT OFF
SET @Out1 = 100 + @Input
SET @Out2 = 'result=开发者_StackOverflow' + CONVERT(varchar,@Out1)
RETURN
END
GO
DECLARE @Out1 int, @Out2 varchar(10)
exec proc_Test @Input=1, @Out1=@Out1, @Out2=@Out2
select @Out1, @Out2
You need to specify vars as output:
DECLARE @Out1 int, @Out2 varchar(10)
exec proc_Test @Input = 1, @Out1 = @Out1 output, @Out2 = @Out2 output
select @Out1, @Out2
As a small matter of style try not to name the vars that receive the results the same as the parameter variables; it gets too confusing.
精彩评论