rollback

Description

Rolls back a user-defined transaction to the named savepoint in the transaction or to the beginning of the transaction.

Syntax

rollback [tran | transaction | work]
	[transaction_name | savepoint_name]

Parameters

tran | transaction | work

specifies that you want to roll back the transaction or the work. If you specify tran, transaction, or work, you can also specify the transaction_name or the savepoint_name.

transaction_name

is the name assigned to the outermost transaction. It must conform to the rules for identifiers.

savepoint_name

is the name assigned to the savepoint in the save transaction statement. The name must conform to the rules for identifiers.

Examples

Example 1

Rolls back the transaction:

begin transaction
delete from publishers where pub_id = "9906"
rollback transaction

Usage


Restrictions


Rolling back an entire transaction


Rolling back to a savepoint


Rollbacks within triggers and stored procedures

Standards

ANSI SQL – Compliance level: Entry-level compliant.

Transact-SQL extensions The rollback transaction and rollback tran forms of the statement and the use of a transaction name.

Permissions

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

See also

Commands begin transaction, commit, create trigger, save transaction