tags:

views:

82

answers:

1

How use output parameter from procedure?

+4  A: 

Assuming that you have a sproc with an output parameter. You can call it and read the output value.

CREATE PROCEDURE AddOne
    @val int,
    @valPlusOne int out

AS
BEGIN
    SET NOCOUNT ON;

    SET @valPlusOne = @val + 1
END
GO

--This is used to store the output
declare @PlusOne int

--This calls the stored procedure setting the output parameter
exec AddOne 1, @valPlusOne=@PlusOne OUT

--This displays the value of the output param
select @Plusone
pjp