In my last post on sp_who2 I demonstrated how this handy utility can help you in your troubleshooting efforts.
Continuing on from this, I am going to cover DBCC INPUTBUFFER
What is DBCC INPUTBUFFER ?
It is a command used to identify the last statement executed by a particular SPID. You would typically use this after running sp_who2
How to use
For example, I have just run run sp_who2 and identified that my lead blocker is SPID number 54 so I would run as follows:
Here is a simple demonstration. In a new query window run this
BEGIN UPDATE Orders SET Amount = 500 WHERE OrderID = 1;
Now in a second query window run this
UPDATE Orders SET Amount = 200 WHERE OrderID = 1;
Now run sp_who2 to identify the lead blocker followed by DBCC INPUTBUFFER using the lead blocker SPID. Here are my results with the column “EventInfo” providing the detail that I need on the T-SQL which is causing the problem. It is possible to copy and paste the code into a query window for analysis.
Permissions needed for DBCC INPUTBUFFER
You need to be a sysadmin or have the VIEW SERVER STATE permission to be able to run this command.
Again, like sp_who2, this handy command should be in your “DBA Toolbox”.