SQL Server error 6401: No transaction or savepoint found
ROLLBACK TRANSACTION name named a savepoint or transaction that doesn't exist, often a misspelling or a savepoint that was never set.
- Error number
6401- Severity
- 16
- Category
- Transactions and locking
What it means
ROLLBACK TRANSACTION name rolls back to the savepoint (or outermost named transaction) with that name. If no savepoint or transaction of that name exists in the current transaction, SQL Server raises 6401. Rolling back to a savepoint doesn't end the transaction; only an unnamed ROLLBACK or the outermost name does.
Common causes
- A typo in the savepoint name, or a
SAVE TRANSACTIONthat was skipped by control flow. - Naming an inner
BEGIN TRANSACTION nameinROLLBACK; only the outermost transaction's name or a savepoint name is valid. - The transaction was already rolled back by an earlier error.
How to fix it
-
Set the savepoint before the work you may need to undo, and roll back to the same name.
BEGIN TRANSACTION; SAVE TRANSACTION BeforeImport; -- work IF @@ERROR <> 0 ROLLBACK TRANSACTION BeforeImport; COMMIT TRANSACTION;
-
Check
XACT_STATE()first: if it's -1, only a fullROLLBACKis possible.
Related errors
3903ROLLBACK has no corresponding BEGIN266Transaction count mismatch after EXECUTE3930Transaction cannot be committed3B001PostgreSQL: invalid savepoint specification
More transactions and locking errors
1205Deadlocked and chosen as the victim1222Lock request time out period exceeded3902COMMIT has no corresponding BEGIN3609Transaction ended in the trigger3960Snapshot isolation update conflict3616Error raised during trigger execution3998Uncommittable transaction rolled back3621The statement has been terminated
The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.
Work on SQL Server in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.