SQL Server数据库阻塞,死锁查询
Posted SpringSun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL Server数据库阻塞,死锁查询相关的知识,希望对你有一定的参考价值。
sql 查询卡顿数据库
SELECT SPID=p.spid,
DBName = convert(CHAR(20),d.name),
ProgramName = program_name,
LoginName = convert(CHAR(20),l.name),
HostName = convert(CHAR(20),hostname),
Status = p.status,
BlockedBy = p.blocked,
LoginTime = login_time,
QUERY = CAST(TEXT AS VARCHAR(MAX))
FROM MASTER.dbo.sysprocesses p
INNER JOIN MASTER.dbo.sysdatabases d
ON p.dbid = d.dbid
INNER JOIN MASTER.dbo.syslogins l
ON p.sid = l.sid
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
WHERE p.blocked = 0
AND EXISTS (SELECT 1
FROM MASTER..sysprocesses p1
WHERE p1.blocked = p.spid)
存储过程查询具体的死锁,阻塞中的sql语句
exec sp_who_lock
以上是关于SQL Server数据库阻塞,死锁查询的主要内容,如果未能解决你的问题,请参考以下文章