SqlRetStatus&

Returns the status number returned by a stored procedure or a remote stored procedure.

Syntax

SqlRetStatus& ( sqlconn% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.

Returns

The return status number for the stored procedure or remote stored procedure.

Remarks

Normally, completed stored procedures return a status number of 0. A RETURN statement in a stored procedure is used for application-specific return status numbers. If a RETURN statement is not used and an error occurs when the stored procedure is executed, SQL Server can return one of the following values:

Value Description
-1 Missing object
-2 Datatype error
-3 Process was chosen as deadlock victim
-4 Permission error
-5 Syntax error
-6 Miscellaneous user error
-7 Resource error, such as out of space
-8 Nonfatal internal problem
-9 System limit was reached
-10 Fatal internal inconsistency
-11 Fatal internal inconsistency
-12 Table or index corrupt
-13 Database is corrupt
-14 Hardware error

Values -15 through -99 are reserved for future SQL Server expansion.

The SqlHasRetStat% function determines whether the most recently executed stored procedure generated a return status number.

The server returns stored procedure information (including any return status and parameter values) immediately after returning all normal results for that stored procedure. Process the normal results, and then call SqlRetStatus& after SqlResults% returns NOMORERPCRESULTS (for all stored procedures in a batch except the last one) or NOMORERESULTS (for a single stored procedure, or for the last stored procedure in a batch).

The order in which the application processes the status number and any returned parameter values is unimportant.

See Also

SqlHasRetStat%, SqlNextRow%, SqlResults%, SqlRetData$