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.

Example

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 © SS64.com 1999-2019
Some rights reserved