--- title: "sys.dm_tran_current_transaction (Transact-SQL)" description: sys.dm_tran_current_transaction (Transact-SQL) author: rwestMSFT ms.author: randolphwest ms.date: "02/27/2023" ms.service: sql ms.subservice: system-objects ms.topic: "reference" f1_keywords: - "sys.dm_tran_current_transaction" - "sys.dm_tran_current_transaction_TSQL" - "dm_tran_current_transaction_TSQL" - "dm_tran_current_transaction" helpviewer_keywords: - "sys.dm_tran_current_transaction dynamic management view" dev_langs: - "TSQL" monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current" --- # sys.dm_tran_current_transaction (Transact-SQL) [!INCLUDE [sql-asdb-asdbmi-asa-pdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw.md)] Returns a single row that displays the state information of the transaction in the current session. > [!NOTE] > To call this from [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)] or [!INCLUDE[ssPDW](../../includes/sspdw-md.md)], use the name **sys.dm_pdw_nodes_tran_current_transaction**. [!INCLUDE[synapse-analytics-od-unsupported-syntax](../../includes/synapse-analytics-od-unsupported-syntax.md)] ## Syntax ``` sys.dm_tran_current_transaction ``` ## Table Returned |Column name|Data type|Description| |-----------------|---------------|-----------------| |**transaction_id**|**bigint**|Transaction ID of the current snapshot.| |**transaction_sequence_num**|**bigint**|Sequence number of the transaction that generates the record version.| |**transaction_is_snapshot**|**bit**|Snapshot isolation state. This value is 1 if the transaction is started under snapshot isolation. Otherwise, the value is 0.| |**first_snapshot_sequence_num**|**bigint**|Lowest transaction sequence number of the transactions that were active when a snapshot was taken. On execution, a snapshot transaction takes a snapshot of all of the active transactions at that time. For nonsnapshot transactions, this column shows 0.| |**last_transaction_sequence_num**|**bigint**|Global sequence number. This value represents the last transaction sequence number that was generated by the system.| |**first_useful_sequence_num**|**bigint**|Global sequence number. This value represents the oldest transaction sequence number of the transaction that has row versions that must be retained in the version store. Row versions that were created by prior transactions can be removed.| |**pdw_node_id**|**int**|**Applies to**: [!INCLUDE[ssazuresynapse-md](../../includes/ssazuresynapse-md.md)], [!INCLUDE[ssPDW](../../includes/sspdw-md.md)]

The identifier for the node that this distribution is on.| ## Permissions On [!INCLUDE[ssNoVersion_md](../../includes/ssnoversion-md.md)] and SQL Managed Instance, requires `VIEW SERVER STATE` permission. On SQL Database **Basic**, **S0**, and **S1** service objectives, and for databases in **elastic pools**, the [server admin](/azure/azure-sql/database/logins-create-manage#existing-logins-and-user-accounts-after-creating-a-new-database) account, the [Azure Active Directory admin](/azure/azure-sql/database/authentication-aad-overview#administrator-structure) account, or membership in the `##MS_ServerStateReader##` [server role](/azure/azure-sql/database/security-server-roles) is required. On all other SQL Database service objectives, either the `VIEW DATABASE STATE` permission on the database, or membership in the `##MS_ServerStateReader##` server role is required. ### Permissions for SQL Server 2022 and later Requires VIEW SERVER PERFORMANCE STATE permission on the server. ## Examples The following example uses a test scenario in which four concurrent transactions, each identified by a transaction sequence number (XSN), are running in a database that has the ALLOW_SNAPSHOT_ISOLATION and READ_COMMITTED_SNAPSHOT options set to ON. The following transactions are running: - XSN-57 is an update operation under serializable isolation. - XSN-58 is the same as XSN-57. - XSN-59 is a select operation under snapshot isolation. - XSN-60 is the same as XSN-59. The following query is executed within the scope of each transaction. ``` SELECT transaction_id ,transaction_sequence_num ,transaction_is_snapshot ,first_snapshot_sequence_num ,last_transaction_sequence_num ,first_useful_sequence_num FROM sys.dm_tran_current_transaction; ``` Here is the result for XSN-59. ``` transaction_id transaction_sequence_num transaction_is_snapshot -------------------- ------------------------ ----------------------- 9387 59 1 first_snapshot_sequence_num last_transaction_sequence_num --------------------------- ----------------------------- 57 61 first_useful_sequence_num ------------------------- 57 ``` The output shows that XSN-59 is a snapshot transaction that uses XSN-57 as the first transaction that was active when XSN-59 started. This means that XSN-59 reads data committed by transactions that have a transaction sequence number lower than XSN-57. Here is the result for XSN-57. ``` transaction_id transaction_sequence_num transaction_is_snapshot -------------------- ------------------------ ----------------------- 9295 57 0 first_snapshot_sequence_num last_transaction_sequence_num --------------------------- ----------------------------- NULL 61 first_useful_sequence_num ------------------------- 57 ``` Because XSN-57 is not a snapshot transaction, `first_snapshot_sequence_num` is `NULL`. ## See Also [Dynamic Management Views and Functions (Transact-SQL)](~/relational-databases/system-dynamic-management-views/system-dynamic-management-views.md) [Transaction Related Dynamic Management Views and Functions (Transact-SQL)](../../relational-databases/system-dynamic-management-views/transaction-related-dynamic-management-views-and-functions-transact-sql.md)