SQL Server error 3903: ROLLBACK has no corresponding BEGIN
ROLLBACK TRANSACTION ran when no transaction was open, typically a second rollback after the transaction was already rolled back.
- Error number
3903- Severity
- 16
- Category
- Transactions and locking
What it means
Like 3902, this means @@TRANCOUNT was 0 when ROLLBACK ran. The usual reason is that the transaction was already rolled back: by an inner procedure, a trigger, XACT_ABORT, or a deadlock. Error handling that always calls ROLLBACK without checking hits this.
Common causes
- A
CATCHblock that callsROLLBACKunconditionally after the transaction was already rolled back. - Both an inner and an outer procedure rolling back.
- A
ROLLBACKwith noBEGIN TRANSACTIONin the batch.
How to fix it
-
Only roll back when a transaction is open.
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;
-
Use
XACT_STATE()inCATCHblocks, which also tells you whether the transaction can still be committed.IF XACT_STATE() <> 0 ROLLBACK TRANSACTION;
Reproduce it safely
ROLLBACK TRANSACTION; -- Msg 3903
Related errors
3902COMMIT has no corresponding BEGIN266Transaction count mismatch after EXECUTE3930Transaction cannot be committed6401No transaction or savepoint found
More transactions and locking errors
1205Deadlocked and chosen as the victim1222Lock request time out period exceeded3609Transaction 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.