赞
踩
https://blog.csdn.net/snowfoxmonitor/article/details/7182948
SQLSERVER
出现死锁查找方法和解决办法
1.查询死锁语句
1.1 blocked<>0
select dbid,* from sys.sysprocesses
where 1=1
and spid >50
and blocked <> 0
查询结果,如图所示
被阻塞的数据库ID:7
备阻塞会话ID:55、57、58
正在阻塞当前会话的ID:58、56
1.2 查询被阻塞的数据
Select name,dbid from master.sys.sysdatabases where dbid=7
1.3 查询被阻塞的表(注意:一定要在被阻塞的数据库中查询)
SELECT
request_session_id spid,
OBJECT_NAME(
resource_associated_entity_id
) tableName
FROM
sys.dm_tran_locks
WHERE
resource_type = 'OBJECT'
1.4 查询阻塞或者死锁的语句
blocked:58
dbcc inputbuffer(58)
2 杀死死锁
blocked:58
kill 58
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。