Sql查看锁信息和被阻塞的进程会话信息:
--查看当前进程会话ID
DECLARE @SessionID int = @@SPID;
--查看当前进程会话持有的锁信息
SELECT * FROM sys.dm_tran_locks WHERE request_session_id = @SessionID
--查看被阻塞的进程会话
SELECT *
FROM sys.dm_tran_locks
WHERE request_status = 'WAIT' AND resource_type <> 'DATABASE';