Wednesday, May 25, 2005
The first step is usually to execute sp_who.
This will list all the tasks and what they are doing. Some of them may be waiting on locks being use by another task. This task will also be in the list, and will helpfully include the user and the machine where this task originated
We can get more information about these tasks from the sysprocesses table, using those spids from sp_who. Here we get to see the name of blocking process, and the process ID on wherever it is being executed.
1> select * from sysprocesses where spid = [spid]
Before you get up and go to that machine and ask the user what he is doing with that application, you can execute sp_lock to get more information about the resource the task is blocking.
The results of sp_lock will reveal what kind of locks, and what object is being locked.
From there we look at sysobjects with the objectid from sp_lock.
1> select * from sysobjects where id = [objectid]
Now you know exactly:
1. Which task is blocking which
2. What those tasks are, including who is running them on which machine
3. Which resource is being blocked
That should give you the information you need to start thinking about how to avoid this problem.