Stored Procedure, when to use Output parameter vs Return variable

前端 未结 7 1486
不思量自难忘°
不思量自难忘° 2020-12-28 12:54

When would you use an output parameter vs a return variable, or vice versa? In the following simple example, I can achieve the same thing using either one.

Using out

7条回答
  •  感动是毒
    2020-12-28 13:29

    taken from here

    • When you want to return one or more items with a data type then it is better to use an output parameter.
    • Generally, use an output parameter for anything that needs to be returned.
    • When you want to return only one item with only an integer data type then it is better to use a return value.
    • Generally, the return value is only to inform success or failure of the Stored Procedure.
    • A return List item a value of 0 indicates success and any non-zero value indicates failure.

提交回复
热议问题