You are on page 1of 1

Investigating locks in SQL Server 2008 / 2012.

A basic explanation on how to find the process that causes lock errors in other processes. The following is valid for SQL Server 2008 and SQL Server 2012: 1. Start SQL Server Management Studio 2. Connect to the correct Database Engine (database server), right click it, and choose Activity Monitor In the Processes window, all active processes are visible including their statuses. Now when a process is trying to get a lock it will be visible in this window: The fields Wait Time (ms), Wait Type, Wait Resource, Blocked By and Head Blocker are filled with some value. 3. Find your database session that is trying to get a lock by looking for an entry with your login and database defined, and an application that matches your bshell or database driver process. (Note that this is only possible when MSQL_LOCK_TIMEOUT has a value that is high enough to go through all shown records) The column Blocked By will show the session ID of the blocking process. 4. Find this session and look at the Application column. This column contains the name of the process (either the msql_srv database driver, or the dbserver_dll driver library), the desktop from where the bshell is started, and the process ID of either the ntbshell or dbdriver process. 5. This information should be sufficient to find out what process and what user is holding the lock.

In the example above, the bshell with process ID 4488 (db session 56, started by user baan on system nlbavwtls17) is waiting for a lock that is blocked by the bshell with process ID 4816 (db session 58, started by user baan on system nlbavwtls17). When stopping or killing the bshell with process ID 4816, the lock will be released, and the bshell with process ID 4488 will be able to continue.

You might also like