You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Marks the starting point of an explicit, local transaction. Explicit transactions start with the BEGIN TRANSACTION statement and end with the COMMIT or ROLLBACK statement.
4
4
author: rwestMSFT
5
5
ms.author: randolphwest
6
-
ms.date: 05/10/2024
6
+
ms.date: 10/27/2025
7
7
ms.service: sql
8
8
ms.subservice: t-sql
9
9
ms.topic: reference
@@ -40,7 +40,7 @@ Marks the starting point of an explicit, local transaction. Explicit transaction
40
40
41
41
## Syntax
42
42
43
-
Syntax for SQL Server, Azure SQL Database, and Azure SQL Managed Instance.
43
+
Syntax for SQL Server, Azure SQL Database, Fabric SQL database, and Azure SQL Managed Instance.
44
44
45
45
```syntaxsql
46
46
BEGIN { TRAN | TRANSACTION }
@@ -50,7 +50,7 @@ BEGIN { TRAN | TRANSACTION }
50
50
[ ; ]
51
51
```
52
52
53
-
Syntax for Synapse Data Warehouse in Microsoft Fabric, Azure Synapse Analytics and Analytics Platform System (PDW).
53
+
Syntax for Fabric Data Warehouse, Azure Synapse Analytics, and Analytics Platform System (PDW).
54
54
55
55
```syntaxsql
56
56
BEGIN { TRAN | TRANSACTION }
@@ -61,19 +61,19 @@ BEGIN { TRAN | TRANSACTION }
61
61
62
62
#### *transaction_name*
63
63
64
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, and Azure SQL Managed Instance
64
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, and Azure SQL Managed Instance
65
65
66
66
The name assigned to the transaction. *transaction_name* must conform to the rules for identifiers, but identifiers longer than 32 characters aren't allowed. Use transaction names only on the outermost pair of nested `BEGIN...COMMIT` or `BEGIN...ROLLBACK` statements. *transaction_name* is always case sensitive, even when the instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] isn't case sensitive.
67
67
68
68
#### *@tran_name_variable*
69
69
70
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, and Azure SQL Managed Instance
70
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, and Azure SQL Managed Instance
71
71
72
72
The name of a user-defined variable containing a valid transaction name. The variable must be declared with a **char**, **varchar**, **nchar**, or **nvarchar** data type. If more than 32 characters are passed to the variable, only the first 32 characters are used. The remaining characters are truncated.
73
73
74
74
#### WITH MARK [ '*description*' ]
75
75
76
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, and Azure SQL Managed Instance
76
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, and Azure SQL Managed Instance
77
77
78
78
Specifies that the transaction is marked in the log. *description* is a string that describes the mark. A *description* longer than 128 characters is truncated to 128 characters before being stored in the `msdb.dbo.logmarkhistory` table.
79
79
@@ -147,7 +147,7 @@ Requires membership in the **public** role.
147
147
148
148
### A. Use an explicit transaction
149
149
150
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Azure SQL Managed Instance, [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], Analytics Platform System (PDW)
150
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, Azure SQL Managed Instance, [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], Analytics Platform System (PDW)
151
151
152
152
```sql
153
153
BEGIN TRANSACTION;
@@ -158,7 +158,7 @@ COMMIT;
158
158
159
159
### B. Rolling back a transaction
160
160
161
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Azure SQL Managed Instance, [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], Analytics Platform System (PDW)
161
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, Azure SQL Managed Instance, [!INCLUDE [ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], Analytics Platform System (PDW)
162
162
163
163
The following example shows the effect of rolling back a transaction. In this example, the `ROLLBACK` statement rolls back the `INSERT` statement, but the created table still exists.
164
164
@@ -172,7 +172,7 @@ ROLLBACK;
172
172
173
173
### C. Name a transaction
174
174
175
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Azure SQL Managed Instance
175
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, Azure SQL Managed Instance
176
176
177
177
The following example shows how to name a transaction.
178
178
@@ -191,7 +191,7 @@ GO
191
191
192
192
### D. Mark a transaction
193
193
194
-
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Azure SQL Managed Instance
194
+
**Applies to:**[!INCLUDE [sql2008-md](../../includes/sql2008-md.md)] and later versions, Azure SQL Database, Fabric SQL database, Azure SQL Managed Instance
195
195
196
196
The following example shows how to mark a transaction. The transaction `CandidateDelete` is marked.
Ignored by the [!INCLUDE [ssDEnoversion](../../includes/ssdenoversion-md.md)]. *transaction_name* specifies a transaction name assigned by a previous `BEGIN TRANSACTION`. *transaction_name*must conform to the rules for identifiers, but can't exceed 32 characters. *transaction_name* indicates to programmers which nested `BEGIN TRANSACTION` the `COMMIT TRANSACTION` is associated with.
65
65
66
66
#### *@tran_name_variable*
67
67
68
-
**Applies to:**[!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] and [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)]
The name of a user-defined variable containing a valid transaction name. The variable must be declared with a char, varchar, nchar, or nvarchar data type. If more than 32 characters are passed to the variable, only 32 characters are used. The remaining characters are truncated.
71
71
72
72
#### WITH DELAYED_DURABILITY = { OFF | ON }
73
73
74
-
**Applies to:**[!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] and [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)]
Option that requests this transaction should be committed with delayed durability. The request is ignored if the database was altered with `DELAYED_DURABILITY = DISABLED` or `DELAYED_DURABILITY = FORCED`. For more information, see [Control Transaction Durability](../../relational-databases/logs/control-transaction-durability.md).
77
77
@@ -112,7 +112,7 @@ COMMIT TRANSACTION;
112
112
113
113
### B. Commit a nested transaction
114
114
115
-
**Applies to:**[!INCLUDE [ssnoversion-md](../../includes/ssnoversion-md.md)] and [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)]
The following example creates a table, generates three levels of nested transactions, and then commits the nested transaction. Although each `COMMIT TRANSACTION` statement has a *transaction_name* parameter, there's no relationship between the `COMMIT TRANSACTION` and `BEGIN TRANSACTION` statements. The *transaction_name* parameters help the programmer ensure that the correct number of commits are coded to decrement `@@TRANCOUNT` to 0 and so to commit the outer transaction.
description: This statement rolls back an explicit or implicit transaction to the beginning of the transaction, or to a savepoint inside the transaction.
0 commit comments