In an application that uses SQL Server I came across a code that uses both OUT and OUTPUT parameters.
@Id INT OUT, @PnNo VARCHAR(10) OUTPUT,
What is the difference between OUT and OUTPUT parameters.
Advertisement
Answer
As noted in the comments, the 2 are synonyms. From the documentation the syntax for the clause is listed as below:
[ VARYING ] [ = default ] [ OUT | OUTPUT | [READONLY] ]
So this denotes that either OUT
or OUTPUT
(or READONLY
) can be supplied for a parameter’s property. Then they are documented as follows:
OUT | OUTPUT Indicates that the parameter is an output parameter. Use OUTPUT parameters to return values to the caller of the procedure. text, ntext, and image parameters cannot be used as OUTPUT parameters, unless the procedure is a CLR procedure. An output parameter can be a cursor placeholder, unless the procedure is a CLR procedure. A table-value data type cannot be specified as an OUTPUT parameter of a procedure.
The pipe (|
) here means an “or”, so eother OUT
or OUTPUT
can be used, but both are documented to do the same thing. Thus which you use is up to you, however, I personally suggest you be consistent and stick to one or the other (or at least the same one in the same object to avoid confusion).