October 2003
Intermediate to advanced
1072 pages
24h 21m
English
As I said earlier, the BEGIN TRAN, COMMIT TRAN, and ROLLBACK TRAN commands are used to manage transactions in Transact-SQL. (The sp_xxxx_xact system stored procedures are legacy code that was used in the past with DB-Library two-phase commit applications, and you should not use them.) The exact syntax used to begin a transaction is:
BEGIN TRAN[SACTION] [name|@TranNameVar]
To commit a transaction, use:
COMMIT TRAN[SACTION] [name|@TranNameVar]
And to roll back a transaction, use:
ROLLBACK TRAN[SACTION] [name|@TranNameVar]
You can also use the COMMIT WORK and ROLLBACK WORK commands in lieu of COMMIT TRANSACTION and ROLLBACK TRANSACTION, though you cannot use transaction names with them.
Read now
Unlock full access