Identifying slow blocking queries on SQL Server

This piece of SQL is perfect for finding which query is running at any particular time, especially if you want to find what it is that’s running very slowly.


This should return a list of what’s running, including process ids (in the first column). Find out what’s causing all the trouble and enter it’s id after spid = below:

DECLARE @Handle binary(20)
SELECT @Handle = sql_handle FROM
  master.dbo.sysprocesses WHERE spid = 55
SELECT * FROM ::fn_get_sql(@Handle)

This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s