Page Top

SqlServer检索挂起的会话

SqlServer中遇到查询耗时长、超时、死锁等情况,通过语句进行检索出数据库中挂起的会话。

SELECT pro.spid AS DialogID,
    DB_NAME(pro.dbid) AS DbName,
    pro.loginame,
    pro.hostname,
    pro.program_name,
    pro.hostprocess AS PorcessID,
    pro.waittime AS [WaitTime(毫秒)],
    sql.text AS sql
    FROM dbo.sysprocesses pro CROSS APPLY sys.dm_exec_sql_text(pro.sql_handle) sql
WHERE pro.status ='suspended'
ORDER BY pro.waittime DESC

 

posted @ 2021-03-17 11:55  抹茶大虾球丶  阅读(154)  评论(0编辑  收藏  举报