Friday 11 October 2013

09. Create a stored procedure that accepts two numbers, num1 and num2, and displays the result after dividing these two numbers. In addition, num1 should always be greater than num2. If num1 is less than num2, generate a user-defined error message, 'You have entered your numbers in the wrong way'.

create Procedure vx_div @Num1 int, @num2 int
as
Begin
Declare @div int
if @Num1<@num2
Raiserror('You have entered your number in the wrong way',16,1)
else
set @div=@Num1/@num2
print @div
end

No comments:

Post a Comment