开发者

Assign a variable to the output of a stored procedure

I am trying to assign the output of a stored procedure to a variable using T-SQL

I have a stored procedure that I pass a varbinary(128) variable and it decrypts it using a key and has an output variable for the decrypted value. I'm not sure if my syntax is correct because when I run the procedure it gives the correct result but when I assign to a variable, then select the variable it is always null

declare @e as varbinary(128)
set @e = *encrypted value*
开发者_开发技巧declare @t as int
set @t = 0
exec *storedprocedure* @data = @e,@t output
select @t

t is null when I select above


Here is a simple example

CREATE PROC myProc @in INT, @out INT OUTPUT
AS 
    SELECT @out = @in+20

GO

DECLARE @in INT, @out INT 

SET @in = 1

EXEC myProc @in= @in, @out=@out OUTPUT

SELECT @out

DROP PROC myProc
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜