This article describes how to view the row Lock wait in MSSQL.
Alibaba Cloud reminds you that:
- Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
- You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
- If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.
You can use the following SQL statement to view the row Lock wait status of the current instance.
WITH CTE_SID ( BSID, SID, sql_handle )
AS ( SELECT [Blocking_Session_ID],
WHERE [Blocking_Session_ID] <> 0
SELECT A.[ Blocking_Session_ID] ,
A.[ Session_ID] ,
FROM sys.dm_exec_requests A
JOIN CTE_SID B ON A.[ Session_ID] = B.BSID
FROM CTE_SID C
JOIN sys.dm_exec_sessions S ON C.sid = s.[ Session_ID]
CROSS APPLY sys.dm_exec_sql_text(C.sql_handle) Q
ORDER BY sid
- If the row lock is waiting or blocked, the results are listed in the execution result.
- BSID is the session id of the lock.
- SID is the session id of the session waiting for the lock.
- ApsaraDB RDS for SQL Server