Articles → SQL SERVER → Transactions In SQL Server
Transactions In SQL Server
What Are Transactions?
Syntax
Begin Transaction -- commit command will make the changes permanent in database
Commit Transaction -- rollback command will cancel the whole transaction
RollBack TRANSACTION
Example
Begin Transaction
Insert Into T1 values('Test1')
Insert Into T2 values('Test1')
Commit Transaction
IF @@ERROR > 0
RollBack TRANSACTION
Begin Transaction
Insert Into T1 values('Test2')
Insert Into T3 values('Test2')
Commit Transaction
IF @@ERROR > 0
RollBack TRANSACTION