笔记289 查看还未提交的事务的SQL语句 2013-6-13

笔记289 查看还未提交的事务的SQL语句 2013-6-13

 1 --查看还未提交的事务的SQL语句 2013-6-13
 2 USE master
 3 GO
 4 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
 5 SELECT es.session_id, es.login_name, es.host_name, est.text
 6   , cn.last_read, cn.last_write, es.program_name
 7 FROM sys.dm_exec_sessions es
 8 INNER JOIN sys.dm_tran_session_transactions st --系统里还存在的事务
 9             ON es.session_id = st.session_id
10 INNER JOIN sys.dm_exec_connections cn
11             ON es.session_id = cn.session_id
12 CROSS APPLY sys.dm_exec_sql_text(cn.most_recent_sql_handle) est
13 LEFT OUTER JOIN sys.dm_exec_requests er                    
14             ON st.session_id = er.session_id
15                 AND er.session_id IS NULL  

 

posted @ 2013-08-04 21:01 桦仔 阅读(...) 评论(...)  编辑 收藏