This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one script to find a list of queries which are blocked by other running queries of SQL Server.
DBAs are always seeking for long running queries, most resources consumed query. Using this script DBA can find list of waiting queries which are not under any type of execution.
DBAs can use this query to prevent the deadlock also because long running block transactions can occur a deadlock situation.
,dese.host_name as HostName
,dest.text AS QueryText
,dest.dbid AS DatabaseID
FROM sys.dm_os_waiting_tasks as dowt
INNER JOIN sys.dm_exec_sessions as dese
ON dowt.session_id = dese.session_id
INNER JOIN sys.dm_exec_requests as der
ON dese.session_id = der.session_id
CROSS APPLY sys.dm_exec_sql_text(der.plan_handle) as dest
CROSS APPLY sys.dm_exec_query_plan(der.plan_handle) as deqp
WHERE dowt.session_id > 50
Here, You can also access few related articles: