Answer the question
In order to leave comments, you need to log in
How to create a procedure in Ms Sql?
Hello!
Please see the code:
alter PROCEDURE SUMOFNUMBERS
@FirstNumber INT,
@SecondNumber INT,
@Answer INT OUT
AS
SET @Answer = @FirstNumber + @SecondNumber;
RETURN @Answer;
GO
Answer the question
In order to leave comments, you need to log in
In your answer, you already wrote how to use the procedure correctly.
If you need to call like "dbo.SUMOFNUMBERS(5,6)". Use a function.
CREATE FUNCTION SUMOFNUMBERS
(
@FirstNumber INT,
@SecondNumber INT
)
RETURNS int
AS
BEGIN
-- Declare the return variable here
DECLARE @Answer int
-- Add the T-SQL statements to compute the return value here
SET @Answer = @FirstNumber + @SecondNumber;
-- Return the result of the function
RETURN @Answer
END
select dbo.SUMOFNUMBERS(5,6)
CREATE PROCEDURE SUMOFNUMBERS
@FirstNumber INT,
@SecondNumber INT,
AS
BEGIN
SET @Answer = @FirstNumber + @SecondNumber;
RETURN @Answer;
END
EXEC @Answer = SUMOFNUMBERS 5, 6
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question