參考網址:
透過下列語法找出疑似SESSION的spid,並KILL它
SELECT request_session_id AS spid,
resource_type AS rt,
resource_databASe_id AS rdb,
(CASE resource_type
WHEN 'OBJECT' then object_name(resource_ASsociated_entity_id)
WHEN 'DATABASE' then '<db_name>'
ELSE
(SELECT object_name(object_id) FROM sys.partitions
WHERE hobt_id = resource_ASsociated_entity_id) END) AS objname,
resource_description AS rd,
request_mode AS rm,
request_status AS rs
FROM sys.dm_tran_locks