DBAtlas · Database operations atlas

3902: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION

SQL Server

What does it mean?

A COMMIT TRANSACTION was executed but there is no corresponding open BEGIN TRANSACTION. No transaction to commit was found because the transaction count (@@TRANCOUNT) is zero.

Why does it happen?

Unbalanced BEGIN/COMMIT/ROLLBACK usage, the transaction already rolled back after an error, incorrect management of nested transaction counts, or calling COMMIT again after ROLLBACK in a CATCH block.

How to fix it

Balance the number of BEGIN and COMMIT statements. Check @@TRANCOUNT before committing (IF @@TRANCOUNT > 0 COMMIT). In TRY...CATCH, on error ROLLBACK based on XACT_STATE()/@@TRANCOUNT and prevent an unnecessary COMMIT. Review nested transaction logic.

Open in DBAtlas →

More from this engine