Explicit Transaction Commands : TRANSACTION « Transaction « SQL Server / T-SQL Tutorial






Command                            Description
BEGIN TRANSACTION                  Sets the starting point of an explicit transaction.
ROLLBACK TRANSACTION               Restores original data modified by a transaction, and brings data back to the state it was in at the start of the transaction. Resources held by the transaction are freed.
COMMIT TRANSACTION                 Ends the transaction if no errors were encountered and makes changes permanent. Resources held by the transaction are freed.
BEGIN DISTRIBUTED TRANSACTION      Allows you to define the beginning of a distributed transaction to be managed by Microsoft Distributed Transaction Coordinator (MS DTC). MS DTC must be running locally and remotely.
SAVE TRANSACTION                   SAVE TRANSACTION issues a savepoint within a transaction, which allows one to define a location to which a transaction can return if part of the transaction is cancelled. A transaction must be rolled back or committed immediately after rolling back to a savepoint.
@@TRANCOUNT                        Returns the number of active transactions for the connection. BEGIN TRANSACTION increments @@TRANCOUNT by 1, and ROLLBACK TRANSACTION and COMMIT TRANSACTION decrements @@TRANCOUNT by 1. ROLLBACK TRANSACTION to a savepoint has no impact.

Quote from:
SQL Server 2005 T-SQL Recipes A Problem-Solution Approach








23.1.TRANSACTION
23.1.1.A transaction is bound by the ACID test. ACID stands for Atomicity, Consistency, Isolation (or Independence), and Durability:
23.1.2.Explicit Transaction Commands
23.1.3.Using Transactions
23.1.4.BEGIN TRANSACTION
23.1.5.Using Explicit Transactions
23.1.6.Forcing an exclusive table lock.
23.1.7.Transaction spread across batches:
23.1.8.Exception before transaction committing
23.1.9.statements coded as a transaction
23.1.10.A script with nested transactions
23.1.11.One batch that contains two transactions
23.1.12.What happens with stored proc transactions and exceptions?
23.1.13.Declare variable in a transaction
23.1.14.Inserting a Row into MyTable and Rolling Back the Transaction