步骤1.查看锁表进程
2.杀死进程
1 --1.查询锁表进程 spid、和被锁表名称 tableName 2 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName 3 from sys.dm_tran_locks 4 where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null 5 6 --2.查询出 kill+锁表进程 7 select 'kill '+ cast(request_session_id as varchar(20)) spid 8 from sys.dm_tran_locks 9 where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null 10 11 --3.直接杀掉 12 kill 91 13 kill 52 14 kill 94 15 kill 56 16 kill 91 17 kill 70 18 kill 52 19 kill 94 20 kill 56 21 kill 56 22 kill 52 23 kill 94 24 kill 91 25 kill 70
把第二个查询列直接复制粘贴运行即可。