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


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




  • rollback transaction without a transaction_name or savepoint_name rolls back a user-defined transaction to the beginning of the outermost transaction.

  • rollback transaction transaction_name rolls back a user-defined transaction to the beginning of the named transaction. Though you can nest transactions, you can roll back only the outermost transaction.

  • rollback transaction savepoint_name rolls a user-defined transaction back to the matching save transaction savepoint_name.

Restrictions for rollback are:
  • If no transaction is currently active, the commit or rollback statement has no effect.

  • The rollback command must appear within a transaction. You cannot roll back a transaction after commit has been entered.

To roll back an entire transaction:
  • rollback without a savepoint name cancels an entire transaction. All the transaction’s statements or procedures are undone.

  • If no savepoint_name or transaction_name is given with the rollback command, the transaction is rolled back to the first begin transaction in the batch. This also includes transactions that were started with an implicit begin transaction using the chained transaction mode.

For rolling back to a savepoint:
  • To cancel part of a transaction, use rollback with a savepoint_name. A savepoint is a marker set within a transaction by the user with the command save transaction. All statements or procedures between the savepoint and the rollback are undone.

  • After a transaction is rolled back to a savepoint, it can proceed to completion (executing any SQL statements after that rollback) using commit, or it can be canceled altogether using rollback without a savepoint. There is no limit on the number of savepoints within a transaction.

For rollbacks within triggers and stored procedures:
  • In triggers or stored procedures, rollback statements without transaction or savepoint names roll back all statements to the first explicit or implicit begin transaction in the batch that called the procedure or fired the trigger.

  • When a trigger contains a rollback command without a savepoint name, the rollback aborts the entire batch. Any statements in the batch following the rollback are not executed.

  • A remote procedure call (RPC) is executed independently from any transaction in which it is included. In a standard transaction (that is, not using Open Client™ DB-Library two-phase commit), commands executed via an RPC by a remote server are not rolled back with rollback and do not depend on commit to be executed.

  • For complete information on using transaction management statements and on the effects of rollback on stored procedures, triggers, and batches, see the Transact-SQL User’s Guide.


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.


No permission is required to use rollback.

Related reference
begin transaction
create trigger
save transaction