查找數據庫中被鎖表代碼:sql
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type='OBJECT'數據庫
字典解釋:session
spid 鎖表進程
tableName 被鎖表名 進程
解鎖方法:ci
declare @spid int
Set @spid = 57 --鎖表進程
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)it