Vikant Pundir
Vikant Pundir

Reputation: 85

Use/Benefit of output parameter in stored procedures

Where do we need to use output parameter in a stored procedure?

Does anyone have any real time experience to share?

I searched a lot but not able to understand proper use of output parameter.

Upvotes: 2

Views: 1401

Answers (3)

Zohar Peled
Zohar Peled

Reputation: 82474

There are many occasions where you want to get some data back from a stored procedure in the form of an output parameter:

  • when inserting data to a table and you need to get the identity value back
  • when performing select statements and you need some extra data
  • when updating or inserting data and you need some way to know if the operation was successful
  • for most if not all of the reasons you need out or ref parameters in c#

There are probably more situations where an output is useful, but I think that should answer your question.

Upvotes: 2

wallyk
wallyk

Reputation: 57774

There are several good answers already, but one not mentioned is when you need the procedure to return more than one variable.

Example: Searching for the highest salary a procedure might also return the I.D. of the person and whether they are still employed.

Upvotes: 1

Rob Conklin
Rob Conklin

Reputation: 9456

It is to pass a value out of the stored procedure. Either a rowset reference, or a scalar value. Think of it as turning stored procedures into function calls.

Upvotes: 0

Related Questions