--检察堵塞正在实行的哀求
select
session_id,blocking_session_id,wait_type,wait_time,wait_resource
from
sys.dm_exec_requests
where
blocking_session_id>0--正在堵塞哀求的会话的ID。假如此列是NULL,则不会堵塞哀求
--检察正在实行的SQL语句
select
a.session_id,sql.text,a.most_recent_sql_handle
from
sys.dm_exec_connectionsa
crossapply
sys.dm_exec_sql_text(a.most_recent_sql_handle)asSQL--也可用函数fn_get_sql经由过程most_recent_sql_handle失掉实行语句
where
a.Session_idin(54,55)
/*
session_idtext
----------------------------------------------------------
54begintranupdatetasetcol2=BBwhereID=2
55begintranselect*fromta
*/