Monitor the running status of database things and database things
Select dbt. DATABASE_ID, DB_NAME (DBT. DATABASE_ID) 'database name', DBT. TRANSACTION_ID,. NAME,. TRANSACTION_BEGIN_TIME, case. TRANSACTION_TYPE WHEN 1 then' read/write TRANSACTION 'when 2 then' read-only TRANSACTION 'when 3 then' system TRANSACTION 'when 4 then' Distributed TRANSACTION 'end' TRANSACTION type', case. TRANSACTION_STATE WHEN 0 then' the transaction has not fully initialized the 'when 1 then' transaction has been initialized, but the 'when 2 then' transaction has not been started. The transaction is active and the 'when 3 then' transaction has ended. This status is used by the read-only transaction 'when 4 then'. The commit process 'when 5 then' has been started for the Distributed Transaction. The transaction is in the ready state and waiting for parsing 'when 6 then'. The transaction has been committed. 7 then' the TRANSACTION is rolling back 'when 8 then' the TRANSACTION has rolled back 'end' TRANSACTION status ', ST. SESSION_ID, TT. text as 'Statement recently executed ', ES. PROGRAM_NAME from sys. DM_TRAN_DATABASE_TRANSACTIONS dbtleft join sys. DM_TRAN_ACTIVE_TRANSACTIONS at on dbt. TRANSACTION_ID =. TRANSACTION_IDLEFT join sys. DM_TRAN_SESSION_TRANSACTIONS st on. TRANSACTION_ID = ST. TRANSACTION_IDLEFT join sys. DM_EXEC_SESSIONS es on st. SESSION_ID = ES. SESSION_IDLEFT join sys. DM_EXEC_CONNECTIONS ec on es. SESSION_ID = EC. SESSION_IDOUTER apply sys. DM_EXEC_ SQL _TEXT (EC. MOST_RECENT_ SQL _HANDLE) TTWHERE ST. SESSION_ID> = 50 AND DATABASE_ID <> 32767