SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Querying deadlock graph from SQL Extended Events

By Marcelo Fonseca,

Hello all,

This is my first time writing a SQL Server post.

I was studying last week about Extended Events and wrote this script to help identify deadlocks using the default XEvent system_health.

I'd like to share it and I'd appreciate if anyone could add suggestions, improvements or fix something, because I haven't tested it on many scenarios.

Basically, all you need is to force a deadlock error and run the script on SQL Server 2008+ filtering by date (if you want) and collect the results. It may take a few seconds to show the new event.

If the object name and/or index name were not shown, you can use the hobt_id value to query the object using sys.partitions (also on column hobt id).

I hope it may help anyone.


Total article views: 4022 | Views in the last 30 days: 11
deadlock graph    
sql server