SQL Server Stored procedure
-
I've created a stored procedure using SQL server query analyzer. The procedure takes single argument which is an output variable and return certain integer value. The procedure is something like this:
CREATE PROCEDURE DBO.MUMAdds
@addtype intoutput
ASSET @addtype=100
return 20GO
Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure. Can anyone tell me that how can i execute this procedure i.e supplying paremeter variable and getting returned value in a variable ????
-
I've created a stored procedure using SQL server query analyzer. The procedure takes single argument which is an output variable and return certain integer value. The procedure is something like this:
CREATE PROCEDURE DBO.MUMAdds
@addtype intoutput
ASSET @addtype=100
return 20GO
Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure. Can anyone tell me that how can i execute this procedure i.e supplying paremeter variable and getting returned value in a variable ????
Shamoon wrote: Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure.
DECLARE @addtype int
execute mumadds @addtype OUTPUT
print @addtypeBut I am not sure how you get the "return 20" back, probably best to make it an output param.
Paul Watson
Bluegrass
Cape Town, South AfricaChristopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)
-
Shamoon wrote: Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure.
DECLARE @addtype int
execute mumadds @addtype OUTPUT
print @addtypeBut I am not sure how you get the "return 20" back, probably best to make it an output param.
Paul Watson
Bluegrass
Cape Town, South AfricaChristopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)
DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT
But it's better to use an output parameter instead... -
DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT
But it's better to use an output parameter instead...Alex Kay wrote: DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT Thanks Alex.
Paul Watson
Bluegrass
Cape Town, South AfricaChristopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)