Implicit Transactions (SQL Server)
Implicit Transactions (SQL Server) is a SQL statement in the Transactions category. SQL Server: when ON, a transaction is automatically started for each DML but requires explicit COMMIT/ROLLBACK. The syntax is SET IMPLICIT_TRANSACTIONS ON;. It returns transaction mode. A typical example: SET IMPLICIT_TRANSACTIONS ON; INSERT INTO audit_log VALUES ('test'); -- Transaction auto-started SELECT @@TRANCOUNT; -- 1 (transaction active) COMMIT; -- Must explicitly commit -- Compare modes: -- AUTOCOMMIT (default): each statement commits immediately -- IMPLICIT: auto-start, manual end -- EXPLICIT: manual start (BEGIN TRAN) and end (COMMIT) A close relative is BEGIN / START TRANSACTION, which begins a new transaction. Changes made within are invisible to others until COMMIT. A close relative is COMMIT, which saves all changes made in the current transaction permanently. A close relative is ROLLBACK, which undoes all changes made in the current transaction (or to a savepoint). More about this category: Transaction control — BEGIN, COMMIT, ROLLBACK, SAVEPOINT, ACID properties.