SQL - Structured Query Language |
COMMIT TransactionCOMMIT Transaction is marks the end of a successful implicit or explicit transaction. If @@TRANCOUNT is 1, COMMIT TRANSACTION makes all data modifications performed since the start of the transaction a permanent part of the database, frees the resources held by the transaction, and decrements @@TRANCOUNT to 0. If @@TRANCOUNT is greater than 1, COMMIT TRANSACTION decrements @@TRANCOUNT only by 1 and the transaction stays active. Syntax -- Syntax --
COMMIT { TRAN | TRANSACTION } [ transaction_name | @tran_name_variable ] ] [ ; ] Transaction_Name Transaction_Name is ignored by the SQL Server Database Engine. Transaction_Name specifies a transaction name assigned by a previous BEGIN TRANSACTION. @Tran_Name_Variable @Tran_Name_Variable is the name of a user-defined variable containing a valid transaction name. Naming a Transaction Example The following example is used to update particular Employee Name. -- Example 65 --
SELECT * FROM EMP
BEGIN TRANSACTION MyTransaction
USE EBusiness GO
UPDATE EMP SET Emp_Name = 'TEST Employee 501' WHERE Emp_Code = 501;
COMMIT TRANSACTION MyTransaction GO
SELECT * FROM EMP Query Output Screen |
* * * * *