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)

Leave a Reply

Your email address will not be published. Required fields are marked *