SQL Server error 3998: Uncommittable transaction rolled back
A batch ended while its transaction was in an uncommittable state (XACT_STATE() = -1), so SQL Server rolled the transaction back.
- Error number
3998- Severity
- 16
- Category
- Transactions and locking
What it means
If an error dooms a transaction and the batch finishes without the code rolling back, SQL Server rolls it back itself at the end of the batch and reports 3998. Any changes in that transaction are gone. It typically appears after a CATCH block that handled an error but didn't roll back.
Common causes
- A
TRY...CATCHthat swallows an error inside a transaction withXACT_ABORT ON, leaving the doomed transaction open. - Errors that doom the transaction regardless of
XACT_ABORT, handled without a rollback.
How to fix it
-
Roll back in every
CATCHblock whenXACT_STATE()isn't 0.BEGIN CATCH IF XACT_STATE() <> 0 ROLLBACK TRANSACTION; THROW; END CATCH -
Find the original error, which
ERROR_MESSAGE()reports in theCATCHblock, and fix it.
Related errors
3930Transaction cannot be committed266Transaction count mismatch after EXECUTE3903ROLLBACK has no corresponding BEGIN
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 execution6401No transaction or savepoint found3621The 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.