rollback trigger

Description

Rolls back the work done in a trigger, including the data modification that caused the trigger to fire, and issues an optional raiserror statement.

Syntax

rollback trigger
	[with raiserror_statement]

Parameters

with raiserror_statement

specifies a raiserror statement, which prints a user-defined error message and sets a system flag to record that an error condition has occurred. This provides the ability to raise an error to the client when rollback trigger is executed so that the transaction state in the error reflects the rollback. For information about the syntax and rules defining raiserror_statement, see the raiserror command.

Examples

Example 1

Rolls back a trigger and issues the user-defined error message 25002:

rollback trigger with raiserror 25002
    "title_id does not exist in titles table."

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

rollback trigger permission defaults to “public.” No permission is required to use it.

See also

Commands create trigger, raiserror, rollback