|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 4:35 PM
Points: 6,369,
Visits: 8,232
|
|
Don't forget that in SQL 2005 +, that the default trace (which starts automatically) captures deadlock graph information. So you can set up a job that fires when this event is raised, and just query that trace file to get the deadlock graph.
If you need help viewing the deadlock graph or figuring out what is going on, I have some code in the "Code Library" section of my blog for reading the deadlock graph and presenting the information in tabular form. It can be found here. This code shows how to get the deadlock graph from the default trace - you could use this in the routine that sends you the notification email.
Wayne Microsoft Certified Master: SQL Server 2008 If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it! Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines, CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: 2 days ago @ 6:55 AM
Points: 217,
Visits: 698
|
|
I made it about two years ago with ı found it in msdn your method is very nice too.
http://msdn.microsoft.com/en-us/library/ms186385.aspx
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: 2 days ago @ 4:30 AM
Points: 4,
Visits: 454
|
|
| Nice article Geoff, I would like to request can u please help us to implement this type of deadlock alert notification proactively rather than re-actively.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:22 PM
Points: 10,571,
Visits: 11,871
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, February 16, 2013 8:50 AM
Points: 1,
Visits: 40
|
|
| This is great and helpful, however, we had to go a little further. We have a severe load of code production deployments as our DBA responsibilities, so we are not always available to deal with Head Blocks right away, but just as soon as possible. Also, Head BLocks occurred as normal part of different processes and they last for a matter of a few seconds, so we do not need to know about all head blocks, but the long lasting ones. So for coping both needs, to be able to check later on and to report only the long lasting ones, we created a process that logs the Activity monitor entries (all columns) for head blocks to a table, and specific code process email alerts for only head blocks longer that 5 minutes. Furthermore, saving historical has increased our Knowledge of what goes on in many other counters, which opens a wide range of possibilities for activity research, analysis, and subsequent corrective actions.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 11:35 AM
Points: 235,
Visits: 329
|
|
I am also loving this! Thanks for contributing! http://www.sqlservercentral.com/Forums/Topic1351590-146-1.aspx
Recently, Grant Fritchey suggested that I stick with Trace Flag 1222 only (see this link). I tried that with your code and pretty much got a blank email - no useful information. So, I went with all three trace flags, and I got much more information in the email. Unfortunately, it still did not bring down the hostname information and clientapp. Sure, we can go to the errorlog to still get it, but I don't see a good way to get that out of the errorlog and into the email. Anyone else see a good way to do it?
Del Lee
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 9:34 AM
Points: 22,
Visits: 47
|
|
Love the script but wanted to be able to deploy this quicker. The final step of creating an alert I simply switched to TSQL and it achieves the same result without having to use the wizard:
--THIS GETS RUN AFTER THE JOB IS CREATED AND WILL CREATE THE ALERT USE [msdb] GO
declare @jobid uniqueidentifier
set @jobid = isnull((select job_id from msdb.dbo.sysjobs where name = 'Deadlock Job'),'00000000-0000-0000-0000-000000000000') set @jobid = LTRIM(rtrim(@jobid)) IF @jobid = '00000000-0000-0000-0000-000000000000' BEGIN RAISERROR('The deadlock job could not be found. Aborting!', 16, 1) RETURN END
IF EXISTS (SELECT name FROM msdb.dbo.sysalerts WHERE name = N'DeadlockAlert') BEGIN RAISERROR('The alert already exists. Aborting!',16,1) RETURN END EXEC msdb.dbo.sp_add_alert @name=N'DeadlockAlert', @message_id=0, @severity=0, @enabled=1, @delay_between_responses=60, @include_event_description_in=0, @category_name=N'[Uncategorized]', @performance_condition=N'SQLServer:Locks|Number of Deadlocks/sec|_Total|>|0', @job_id= @jobid GO
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 11:42 PM
Points: 424,
Visits: 55
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 9:34 AM
Points: 22,
Visits: 47
|
|
| This was working like a champ for about a month and then suddenly SQL would email me and it would always say 0 rows affected. Anybody else run across this?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Yesterday @ 5:08 AM
Points: 2,
Visits: 100
|
|
Hi , I am getting email when a deadlock happens but i am getting a blank attachment due to which i am not able to know the actual cause of the deadlock
|
|
|
|