I have been troubleshooting an issue within a database that has some serious blocking issues.
I found the command DBCC INPUTBUFFER
a while back that allows me to see the query run for that spid. I have used this to see what is running and causing the issue.
What I am confused about is that the query that DBCC INPUTBUFFER
shows does not include the variables associated with the query. For example, if the query joined on the @ID
of a table, the provided query by DBCC INPUTBUFFER
does not show the @ID
value.
I am just wondering if there is a way to see what variable is associated with the query. And/or if maybe this is not the norm and normally DBCC INPUTBUFFER
should show you the variable associated with the query.
If it is the latter, then my problem probably rests in the fact that a variable is not being provided and it is just querying a set of rather enormous tables and taking an eternity.
Best Answer
I would suggest, you should use either of below for troubleshooting blocking problems :
You can use beta_lockinfo by Erland Sommarskog
Another method is to use sp_whoIsActive by Adam Machanic with
@get_locks = 1
and dump the data into a table for analysisThere are other ways like Blocked Process Report Event Class or if you are using sql server 2008 and up, then Extended events, but above ones will give you the details that you are looking without much effort.