Rolls back the work done in a trigger, including the data modification that caused the trigger to fire, and issues an optional raiserror statement.
rollback trigger [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.
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."
When rollback trigger is executed, Adaptive Server aborts the currently executing command and halts execution of the rest of the trigger.
If the trigger that issues rollback trigger is nested within other triggers, Adaptive Server rolls back all work done in these triggers up to and including the update that caused the first trigger to fire.
Adaptive Server ignores a rollback trigger statement that is executed outside a trigger and does not issue a raiserror associated with the statement. However, a rollback trigger statement executed outside a trigger but inside a transaction generates an error that causes Adaptive Server to roll back the transaction and abort the current statement batch.
ANSI SQL – Compliance level: Transact-SQL extension.
No permission is required to use rollback trigger.
Commands create trigger, raiserror, rollback