In this tutorial we will learn how to add two number and return with output parameter in sql stored procedure. Once we must execute the code below and get succesful message:
1 2 3 4 5 | Create Procedure AddTwoNumber(@p1 int,@p2 int,@Result int output) as Begin Set @Result = @p1+ @p2 End |
Before to execute the procedure we must define a variable to keep the result Than we can execute the Stored Procedure with any values you want and we can learn the result with select statement;
1 2 3 | Declare @r int Execute AddTwoNumber 20,25,@r output Select @r as Result |
Result Of The Code : 45