SELECT DBT. database_id, Db_name (DBT). database_id) ' database name ', DBT. transaction_id, At.name, at. Transaction_begin_time, case at. 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 at. Transaction_state when 0 Then ' transaction has not been fully initialized ' when 1 Then ' transaction has been initialized but not started ' when 2 Then ' transaction is live State ' when 3 then ' transaction has ended. This state is used for read-only transactions ' when 4 then ' has initiated a commit process to a distributed transaction ' when 5 Then ' transaction is in a ready state and waits for parsing ' when 6 then ' transaction has been raised Turn ' when 7 then ' transaction is being rolled back ' when 8 then ' transaction rolled back ' END ' transaction state ', ST. session_id, TT. TEXT as ' recently executed statement ', ES. Program_name from SYS. Dm_tran_database_transactions dbtleft JOIN SYS. Dm_tran_active_transactions at on DBT. transaction_id = at. 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 >= database_id <> 32767
Monitor the operation of database things