T-SQL Tutorial

T-SQL Rollback Transaction


The ROLLBACK Transaction is an operation that rolls back an unsuccessful explicit or implicit transaction to the beginning of the transaction or to a save point inside the transaction.

Rollback transaction syntax:

ROLLBACK { TRAN | TRANSACTION }
[ transaction_name | @transaction_name_variable
| savepoint_name | @savepoint_variable ] ;

Rollback transaction example:

USE model;
GO
BEGIN TRANSACTION;
GO
insert into students(id,first_name, last_name, gender,city, country, section)
values(8,'Alysia','MARTIN','F','Toronto','Canada', 'Biology');
GO
ROLLBACK TRANSACTION;
GO