Show TOC

SAVE TRANSACTION Statement [T-SQL]Locate this document in the navigation structure

Establishes a savepoint within the current transaction.

Syntax
SAVE TRANSACTION [ <savepoint-name> ]
Parameters

(back to top)

  • savepoint-name an identifier that can be used in a ROLLBACK TRANSACTION statement. All savepoints are automatically released when a transaction ends.
Examples

(back to top)

  • Example 1 returns five rows with values 10, 20, and so on. The effect of the delete, but not the prior inserts or update, is undone by the ROLLBACK TRANSACTION statement:
    BEGIN
         SELECT row_num INTO #tmp 
         FROM sa_rowgenerator( 1, 5 ) 
         UPDATE #tmp SET row_num=row_num*10
         SAVE TRANSACTION before_delete
         DELETE FROM #tmp WHERE row_num >= 3
         ROLLBACK TRANSACTION before_delete
         SELECT * FROM #tmp
    END
Standards

(back to top)

  • SQL—Vendor extension to ISO/ANSI SQL grammar.
Permissions