It is used to rollback the last transactions, if transactions not commit.
Syntax:
ROLLBACK;
Let’s understand with an example:
Step 1: Sample data as below:

Step 2: Now, delete all records from Students Table using BEGIN TRAN command.
Query:
BEGIN TRAN T1 DELETE Students --T1 : is Transaction name --Execute both query together

Step 3:Â Now all records has been deleted.
SELECT * FROM Students

Step 4: But we used BEGIN TRAN before SQL Query statement, so it holds the transaction until the transaction is either committed or rolled back.
Step 5: Â Now we rolled back the Transaction.
ROLLBACK TRAN T1

Step 6: check again the table all records rolled back or not?
SELECT * FROM Students

As you saw, all records rolled back successfully!
Hope you enjoy the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.
![]()
