BEGIN TRANSACTION

Mark the starting point of an explicit, local transaction.

Syntax
      BEGIN TRAN[SACTION] [transaction [WITH MARK ['description'] ] [;]

      BEGIN TRAN[SACTION] [@transaction_var [WITH MARK ['description'] ] [;]

 Key:
   transaction     A name for the transaction <= 32 characters.
   transaction_var A user-defined variable containing a transaction name.
   WITH MARK       Note the transaction in the log.

This will increment @@TRANCOUNT by 1.

Examples

DECLARE @MyTran VARCHAR(20);
SELECT @MyTran = 'MyTransaction';

BEGIN TRANSACTION @MyTran;
USE MyDatabase;
DELETE FROM MyDatabase.MySchema.MyTable WHERE MyColumn = 123;

COMMIT TRANSACTION @MyTran;
GO

"The two offices of memory are collection and distribution" - Dr. Johnson

Related commands

COMMIT TRANSACTION
Equivalent Oracle command: SAVEPOINT


 
Copyright © 1999-2024 SS64.com
Some rights reserved