From 8d2d4ea028bee97bbc83b5453958bf24395328ac Mon Sep 17 00:00:00 2001 From: Masayuki Ozawa Date: Thu, 28 Dec 2017 15:14:41 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=88=86=E9=9B=A2=E3=83=AC=E3=83=99?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E6=83=85=E5=A0=B1=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\343\201\256\347\242\272\350\252\215.sql" | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 "Transaction/\343\203\210\343\203\251\343\203\263\343\202\266\343\202\257\343\202\267\343\203\247\343\203\263\345\210\206\351\233\242\343\203\254\343\203\231\343\203\253\343\201\256\347\242\272\350\252\215.sql" diff --git "a/Transaction/\343\203\210\343\203\251\343\203\263\343\202\266\343\202\257\343\202\267\343\203\247\343\203\263\345\210\206\351\233\242\343\203\254\343\203\231\343\203\253\343\201\256\347\242\272\350\252\215.sql" "b/Transaction/\343\203\210\343\203\251\343\203\263\343\202\266\343\202\257\343\202\267\343\203\247\343\203\263\345\210\206\351\233\242\343\203\254\343\203\231\343\203\253\343\201\256\347\242\272\350\252\215.sql" new file mode 100644 index 0000000..89a5724 --- /dev/null +++ "b/Transaction/\343\203\210\343\203\251\343\203\263\343\202\266\343\202\257\343\202\267\343\203\247\343\203\263\345\210\206\351\233\242\343\203\254\343\203\231\343\203\253\343\201\256\347\242\272\350\252\215.sql" @@ -0,0 +1,65 @@ +SELECT + s.session_id, + CASE s.transaction_isolation_level + WHEN 0 THEN 'Unspecified' + WHEN 1 THEN 'ReadUncommitted' + WHEN 2 THEN 'ReadCommitted' + WHEN 3 THEN 'Repeatable' + WHEN 4 THEN 'Serializable' + WHEN 5 THEN 'Snapshot' + END AS Transaction_Isolation_Level , + s.host_name, + s.program_name, + s.client_interface_name, + s.login_name, + s.nt_domain, + s.nt_user_name, + s.status, + st.enlist_count, + st.is_user_transaction, + st.is_local, + st.is_enlisted, + st.is_bound, + st.open_transaction_count, + CASE at.transaction_type + WHEN 1 THEN 'Read/write' + WHEN 2 THEN 'Read-only' + WHEN 3 THEN 'System' + WHEN 4 THEN 'Distributed' + END as transaction_type, + at.transaction_uow, + CASE at.transaction_state + WHEN 0 THEN 'The transaction has not been completely initialized yet.' + WHEN 1 THEN 'The transaction has been initialized but has not started.' + WHEN 2 THEN 'The transaction is active.' + WHEN 3 THEN 'The transaction has ended. This is used for read-only transactions.' + WHEN 4 THEN 'The commit process has been initiated on the distributed transaction. This is for distributed transactions only. The distributed transaction is still active but further processing cannot take place.' + WHEN 5 THEN 'The transaction is in a prepared state and waiting resolution.' + WHEN 6 THEN 'The transaction has been committed.' + WHEN 7 THEN 'The transaction is being rolled back.' + WHEN 8 THEN 'The transaction has been rolled back.' + END AS transaction_state, + CASE dtc_state + WHEN 1 THEN 'ACTIVE' + WHEN 2 THEN 'PREPARED' + WHEN 3 THEN 'COMMITTED' + WHEN 4 THEN 'ABORTED' + WHEN 5 THEN 'RECOVERED' + ELSE CAST(dtc_state AS nvarchar(50)) + END AS dtc_state + +FROM + sys.dm_exec_sessions s + LEFT JOIN + sys.dm_tran_session_transactions st + ON + s.session_id = st.session_id + LEFT JOIN + sys.dm_tran_active_transactions at + ON + st.transaction_id = at.transaction_id + +WHERE + st.is_user_transaction = 1 + AND + s.session_id > 50 \ No newline at end of file