save transaction

Sets a savepoint within a transaction.

Syntax

save transaction savepoint_name 

Parameters

Examples

Usage

  • A savepoint is a user-defined marker within a transaction that allows portions of a transaction to be rolled back. rollback savepoint_name rolls back to the indicated savepoint; all statements or procedures between the savepoint and the rollback are undone.

    Statements preceding the savepoint are not undone—but neither are they committed. After rolling back to the savepoint, the transaction continues to execute statements. A rollback without a savepoint cancels the entire transaction. A commit allows it to proceed to completion.

  • If you nest transactions, save transaction creates a savepoint only in the outermost transaction.

  • There is no limit on the number of savepoints within a transaction.

  • If no savepoint_name or transaction_name is given with the rollback command, all statements back to the first begin transaction in a batch are rolled back, and the entire transaction is canceled.

See also Transact-SQL User’s Guide for using transaction statements.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

No permission is required to use save transaction.

Related reference
begin transaction
commit
rollback