I have a stored procedure with 25 output parameters. Should all these parameters be supplied / declared or is there a way to selectively declare just a few?
SQL Server stored procedure - Output Parameters
2.6k Views Asked by Jarvis Bot At
2
There are 2 best solutions below
0

You must declare all of the parameters in the stored procedure definition and in the actual call or execution of the stored procedure, as well as specifying the OUTPUT keyword in declaration and call.
Example:
CREATE PROCEDURE gtest (
@col1 int,
@col2 int OUTPUT,
@col3 int OUTPUT
)AS
SET @col2=@col1;
SET @col3=@col1*@col1;
GO
DECLARE @out INT, @out3 int;
EXEC gtest 12, @out output, @out3 output
SELECT @out, @out3
You have to declare all the assigned OUTPUT parameters in your Execute statement.