--1.查询锁表进程 spid、和被锁表名称 tableName
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks
where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null
--2.查询出 kill+锁表进程
select 'kill '+ cast(request_session_id as varchar(20)) spid
from sys.dm_tran_locks
where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null
--3.直接杀掉
kill 74
kill 65
kill 74
kill 61
kill 79
kill 77
kill 74