首页 > 代码库 > sqlserver锁表查看

sqlserver锁表查看

sp_lock–查询哪个进程锁表了,spid:进程ID,ObjId:对象ID

EXEC sp_executesql N‘KILL [spid]‘–杀进程

select object_name([ObjId])–查询哪张表被锁

使用sql语句进行查看
select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableName
from sys.dm_tran_locks where resource_type=‘OBJECT‘

sqlserver锁表查看