To begin a transaction, issue the BEGIN TRANSACTION (or BEGIN TRAN) statement.
This tells SQL Server that all the following changes to the database occur as a unit of work.
Syntax for BEGIN TRANSACTION
BEGIN TRAN [ SACTION ] [ transaction_name | @tran_name_variable
[ WITH MARK [ 'description' ] ] ]
If you decide that all is well, you can issue the COMMIT TRAN or COMMIT WORK statement. Syntax for COMMIT TRAN and COMMIT WORK
COMMIT [ TRAN [ SACTION ] [ transaction_name | @tran_name_variable ] ]
COMMIT [ WORK ]
If you need to undo all of your work, you can issue a ROLLBACK TRAN or ROLLBACK WORK statement.
Syntax for ROLLBACK TRAN and ROLLBACK WORK
ROLLBACK [ TRAN [ SACTION ]
[ transaction_name | @tran_name_variable
| savepoint_name | @savepoint_variable ] ]
ROLLBACK [ WORK ]
|