3902: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION
SQL ServerWhat 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.
More from this engine
- 2714There is already an object named in the database
- 601Could not continue scan with NOLOCK due to data movement
- 50000Custom error raised with RAISERROR
- 1101Could not allocate a new page because of insufficient disk space in filegroup
- 3729Cannot DROP because it is being referenced by object
- 3961Snapshot isolation transaction failed because the object was modified by a DDL statement
- 1785Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths