In this post we will write a stored Procedure. We will divide numbers than we will get divided value and remaining value by output parameter.
1 2 3 4 5 6 7 8 9 10 |
Create Procedure sp_Devide(@n1 int,@n2 int,@division int output,@remaining int output) as Begin SEt @division = 0 While(@n2<=@n1) Begin Set @n1 = @n1-@n2 Set @division+=1 End Set @remaining = @n1 End |
After running the code above we will get succesful message, than we may run the codes below
Ex1
1 2 3 |
Declare @d int,@r int Execute sp_Devide 34,7,@d output,@r output Select @d Division,@r Remaining |
Result
Ex2
1 2 3 |
Declare @d int,@r int Execute sp_Devide 25,4,@d output,@r output Select @d Division,@r Remaining |
Result