Deadlocks are usually detected and resolved automatically by SQL Server by killing one of the SPIDs involved in it. You may have an alert setup to notify you and/or users may approach you with the issue. But this post is not about finding the root cause and fix the issue for good. Ideally, you don't want to see dead locks occur at all and especially not on a regular basis. But situations could arise where a database starts experiencing deadlocks. In this post I would like to share a code I have used to capture the daily count of deadlocks for a trending report. Note: I am using the DMV sys.dm_os_performance_counters in this code so it will not work if the SQL Server performance counters are disabled for some reason. You can use this query to check if the performance counters are enabled or disabled. SELECT COUNT (*) FROM sys . dm_os_performance_counters ; If the return value is 0 rows, the performance counters have been disa...