Mark the starting point of an explicit, local transaction. The concept of the transaction is to consider multiple tasks as a single unit. The transaction when completes, it either performs all of the tasks within it or none.
Thus a transaction is either implemented completely or is not implemented at all and has no intermediate state.
Syntax :
BEGIN TRAN[SACTION] [transaction [WITH MARK ['description'] ]
BEGIN TRAN[SACTION] [@transaction_var [WITH MARK ['description'] ]
Description ::
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.
Transaction Type
1- Begin Tran
2- Commit Tran
3- Rollback Tran
Example ::
DECLARE @MyTranName VARCHAR(20);
SET @MyTranName = 'deleteTran';
BEGIN TRANSACTION @MyTranName
DELETE FROM emp WHERE empcode = 123;
COMMIT TRANSACTION @MyTranName
Note :: @@TRANCOUNT = Count Number of transaction is open.
No comments:
Post a Comment