Transaction and Checkpoint in SQL Server

Vaishali
2 min readDec 9, 2019

--

TRANSACTION: The transaction helps to group the set of task, either all transaction are success or all revert back.

In this article, I have created a table with two columns ID and NAME also primary key apply on ID.

TABLE_1
  • Begin transaction is a starting point of transaction.
  • In this transaction, we insert some value into the table. Both insert query in one logical unit.
BEGIN TRANSACTION
  • Rollback transaction is a reverted back transaction if either failure or mistake occurs.
  • This transaction will revert back due to a violation of the primary key.
ROLLBACK TRANSACTION
  • Commit transaction to save changes to the database. In this transaction successfully inserted values in the table.
COMMIT TRANSACTION

Nested Transaction means transaction inside a transaction.

  • Any rollback applies on an inner transaction it rollbacks everything. If we executed nested transaction it rollbacks everything.
NESTED TRANSACTION

CHECKPOINT: The checkpoint is a logical completion point where someone wants to rollback it.

  • A checkpoint is a process that writes current in-memory dirty pages (modified pages) and transaction log records to a physical disk.
  • SQL Server checkpoints are used to reduce the time required for recovery in the event of system failure.
  • In checkpoint, If an error occurs that statement has terminated and others will be executed.
CHECKPOINT
  • Test3 and Test4 have been terminated because of a violation of the primary key.
  • Test5 and Test6 successfully inserted in the table.
RESULT OF CHECKPOINT

If you are a newbie to database learning — SQL Server recommended is the following must-watch video: -

--

--

No responses yet