Sunday, 4 October 2026

can we rollback after commit

 No. Once a transaction is committed, it cannot be rolled back using the ROLLBACK statement.

After COMMIT, SQL Server considers the transaction permanently completed. The transaction log contains a LOP_COMMIT_XACT record, locks are released, and @@TRANCOUNT becomes 0. Since there is no active transaction, SQL Server has nothing to roll back.

Let’s see the demo

BEGIN TRANSACTION; 

UPDATE Account

SET Balance = Balance + 10000

WHERE AccountNumber = 'SB100001';

 COMMIT;

 

This is a complete transaction.

Not we are running the ROLLBACK on this session. we will get the error.

Getting this error because there is not active transaction.

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts