Creating Stored Procedure with Output Variable

In Programming & Software Support by RJ Regalado,
posted 4 years ago

Create a stored procedure that will add 2 variables

CREATE PROCEDURE SumVariables
	@var1 INT,
	@var2 INT,
	@varTotal INT OUTPUT
AS
BEGIN
	SET @varTotal = COALESCE(@var1,0) + COALESCE(@var2, 0)
END

 Call the sumVariables procedure

DECLARE	@result INT
EXEC	sumVariables 2,3, @result OUTPUT
SELECT	@result

 

Back To Programming & Software Support