T-SQL Tutorial

T-SQL Begin Transaction


The Begin Transaction statement is the start point of an explicit transaction and increments @@TRANCOUNT by 1.

Begin Transaction syntax:

BEGIN { TRAN | TRANSACTION }
[ { transaction_name | @transaction_name_variable }
[ WITH MARK [ 'transaction description' ] ] ];





Begin Transaction example:

BEGIN TRANSACTION DelStudent WITH MARK N'Delete student';
GO
USE model;
GO
DELETE FROM students WHERE id = 7 and section = 'History';
GO
COMMIT TRANSACTION DelStudent;
GO