How do I figure out what query is being run by a process?

Here’s a helpful hint provided by Michael Herfkens of OpSource. If you’ve got a misbehaving process in SQL Server (hogging CPU or the root cause of excessive locking or whatever) and you want to know, “What in the world is that process doing?” you just right click on the SPID and select Details and… OH! Blank! Here’s the trick:

All you need to do to pull back the information about what is being run is to open a query window and run the following statement:

DBCC INPUTBUFFER(78)

where 78 is the SPID whose activity you want to look at.

Michael

Thanks, Michael!

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: