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:
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.