Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

sys.dm_tran_current_snapshot (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns a virtual table that displays all active transactions at the time when the current snapshot transaction starts. If the current transaction is not a snapshot transaction, this function returns no rows. sys.dm_tran_current_snapshot is similar to sys.dm_tran_transactions_snapshot, except that sys.dm_tran_current_snapshot returns only the active transactions for the current snapshot transaction.

Applies to: SQL Server (SQL Server 2008 through current version), SQL Database V12, Azure SQL Data Warehouse Public Preview.

Note Note

To call this from SQL Data Warehouse, use the name sys.dm_pdw_nodes_tran_current_snapshot.

sys.dm_tran_current_snapshot

Column name

Data type

Description

transaction_sequence_num

bigint

Transaction sequence number of the active transaction.

On SQL Server requires VIEW SERVER STATE permission on the server.

On SQL Database Premium Tiers requires the VIEW DATABASE STATE permission in the database. On SQL Database Standard and Basic Tiers requires the SQL Database admin account.

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 XSN-59.

SELECT 
    transaction_sequence_num
  FROM sys.dm_tran_current_snapshot;

Here is the result set.

transaction_sequence_num
------------------------
57
58

The results show that XSN-57 and XSN-58 were active at the time that the snapshot transaction XSN-59 started. This same result persists, even after XSN-57 and XSN-58 commit or roll back, until the snapshot transaction finishes.

The same query is executed within the scope of XSN-60.

Here is the result set.

transaction_sequence_num
------------------------
57
58
59

The output for XSN-60 includes the same transactions that appear for XSN-59, but also includes XSN-59, which was active when XSN-60 started.

Community Additions

ADD
Show:
© 2015 Microsoft