CONTINUE_AFTER_RAISERROR Option [TSQL]

Controls behavior following a RAISERROR statement.

Allowed Values

ON, OFF

Default

ON

Description

The RAISERROR statement is used within procedures to generate an error. When CONTINUE_AFTER_RAISERROR is set to OFF, the execution of the procedure is stopped when the RAISERROR statement is encountered.

When CONTINUE_AFTER_RAISERROR is ON, the RAISERROR statement no longer signals an execution-ending error. Instead, the RAISERROR status code and message are stored and the most recent RAISERROR is returned when the procedure completes. If the procedure that caused the RAISERROR was called from another procedure, the RAISERROR is not returned until the outermost calling procedure terminates.

Intermediate RAISERROR statuses and codes are lost after the procedure terminates. If, at return time, an error occurs along with the RAISERROR, then the error information is returned and the RAISERROR information is lost. The application can query intermediate RAISERROR statuses by examining @@error global variable at different execution points.

The setting of CONTINUE_AFTER_RAISERROR is used to control behavior following a RAISERROR statement only if the ON_TSQL_ERROR option is set to CONDITIONAL (the default). If you set the ON_TSQL_ERROR option to STOP or CONTINUE, the ON_TSQL_ERROR setting takes precedence over the CONTINUE_AFTER_RAISERROR setting.

Related reference
ON_TSQL_ERROR Option [TSQL]