Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output parameter in Stored Prodedure

Status
Not open for further replies.

5679

Programmer
Feb 14, 2003
32
AU
I need to write a stored procedure with two output parameters. Please give me an example or an idea.
 
Have you searched in BOL ?

I typed in .. output parameters and got a whole load ..

CREATE PROCEDURE myProc
@inparam int,
@outparam int OUTPUT


I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
You also need to specify OUTPUT when calling the stored procedure. e.g.

Code:
CREATE PROCEDURE myProc 
    @inparam int,
    @outparam1 int OUTPUT,
    @outparam2 int OUTPUT
AS
SELECT @outparam1=49*@inparam

SELECT @outparam2=49*@outparam2

Calling script/procedure

Code:
DECLARE @q1 integer, @q2 integer

SELECT @q2=4

EXECUTE myProc 100, @q1 OUTPUT, @q2 OUTPUT

SELECT @q1, @q2

Above returns a single row:

4900 196

Have fun
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top