| description | Transactions (Transact-SQL) | ||||
|---|---|---|---|---|---|
| title | Transactions (Transact-SQL) | Microsoft Docs | ||||
| ms.custom | |||||
| ms.date | 09/25/2017 | ||||
| ms.prod | sql | ||||
| ms.prod_service | database-engine, sql-database, synapse-analytics, pdw | ||||
| ms.reviewer | |||||
| ms.technology | t-sql | ||||
| ms.topic | reference | ||||
| f1_keywords |
|
||||
| dev_langs |
|
||||
| helpviewer_keywords |
|
||||
| ms.assetid | 1485c375-921a-42af-a871-bb333cc08d3e | ||||
| author | LitKnd | ||||
| ms.author | kendralittle | ||||
| monikerRange | >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDE sql-asdb-asdbmi-asa-pdw]
A transaction is a single unit of work. If a transaction is successful, all of the data modifications made during the transaction are committed and become a permanent part of the database. If a transaction encounters errors and must be canceled or rolled back, then all of the data modifications are erased.
[!INCLUDEssNoVersion] operates in the following transaction modes:
Autocommit transactions
Each individual statement is a transaction.
Explicit transactions
Each transaction is explicitly started with the BEGIN TRANSACTION statement and explicitly ended with a COMMIT or ROLLBACK statement.
Implicit transactions
A new transaction is implicitly started when the prior transaction completes, but each transaction is explicitly completed with a COMMIT or ROLLBACK statement.
Batch-scoped transactions
Applicable only to multiple active result sets (MARS), a [!INCLUDEtsql] explicit or implicit transaction that starts under a MARS session becomes a batch-scoped transaction. A batch-scoped transaction that is not committed or rolled back when a batch completes is automatically rolled back by [!INCLUDEssNoVersion].
Note
For special considerations related to Data Warehouse products, see Transactions (Azure Synapse Analytics).
[!INCLUDEssNoVersion] provides the following transaction statements:
:::row:::
:::column:::
BEGIN DISTRIBUTED TRANSACTION
:::column-end:::
:::column:::
ROLLBACK TRANSACTION
:::column-end:::
:::row-end:::
:::row:::
:::column:::
BEGIN TRANSACTION
:::column-end:::
:::column:::
ROLLBACK WORK
:::column-end:::
:::row-end:::
:::row:::
:::column:::
COMMIT TRANSACTION
:::column-end:::
:::column:::
SAVE TRANSACTION
:::column-end:::
:::row-end:::
:::row:::
:::column:::
COMMIT WORK
:::column-end:::
:::column:::
:::column-end:::
:::row-end:::
SET IMPLICIT_TRANSACTIONS (Transact-SQL)
@@TRANCOUNT (Transact-SQL)