I have written some T-SQL that will return the results of a blocked process by producing the entire blocking chain. Since we are only allowed to return one result in custom alerts can someone help me out. I would like to be able to use the results of this query which can be used to identify the chain of a blocked process, and I am not sure how to go about it.
SELECT waiting_task_address,
session_id,
exec_context_id,
wait_duration_ms,
wait_type,
resource_address,
blocking_task_address,
blocking_session_id,
blocking_exec_context_id,
resource_description
FROM sys.dm_os_waiting_tasks
WHERE blocking_session_id IS NOT NULL;
GO
This is both the condition to fire an alert, and the information most helpful in the alert resolution. I would like to create an alert that runs this, and if any blocked processes are returned. Send an email with the information returned from the above.