Author |
Topic |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-09 : 09:24:08
|
Deadlocks are occuring during on server.I need a script to setup an email alert when the deadlock occured. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-03-09 : 09:40:31
|
EXEC msdb.dbo.sp_add_alert @name=N'Deadlock', @message_id=0, @severity=0, @enabled=1, @delay_between_responses=0, @include_event_description_in=1, @category_name=N'[Uncategorized]', @performance_condition=N'SQLServer:Locks|Number of Deadlocks/sec|_Total|>|0', @job_id=N'00000000-0000-0000-0000-000000000000'GOOnce that alert is created, you'll have to right-click it under SQL Agent and add the option to Notify Operators. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-09 : 10:09:18
|
Thanks Robvolk.I am new deadlocks stuff..Please let me know how to identity the which database and query is causing the deadlock..do i need to enable the dbcc trace also.Please suggest me if extended events can be used for alerts.. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-09 : 10:16:55
|
I have enable the operators as mentioned.. i need to enable the execute the job option in the alert. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-09 : 12:42:23
|
Thanks for the below links and i will go through it.MeanwhilePlease correct me the below scritp should alert when the deadlocks occured..EXEC msdb.dbo.sp_add_alert @name=N'Deadlock', @message_id=0, @severity=0, @enabled=1, @delay_between_responses=0, @include_event_description_in=1, @category_name=N'[Uncategorized]', @performance_condition=N'SQLServer:Locks|Number of Deadlocks/sec|_Total|>|0', @job_id=N'00000000-0000-0000-0000-000000000000'GO |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-03-09 : 22:11:22
|
That script creates an alert on SQL Server, but it doesn't add notifications. You have to add those manually through Management Studio, as I mentioned earlier. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-11 : 11:39:33
|
Thanks .I have created the alerts and setup notification. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-12 : 13:02:44
|
I put the alert and setup the notitication but there was deadlock happend but didn't email the alert about the deadlock..Please suggest.. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-03-12 : 13:40:24
|
Did you configure Database Mail on that server? Make sure to set up a default mail profile as well. Once that's done right-click on SQL Server Agent in Object Explorer, choose Properties, and go to the Alert System panel to enable Database Mail. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-12 : 13:47:56
|
Database mail was already configured..but there is any alert already exist with same jobid could that be a problem but when i tried to see property of the alert then i got the error..TITLE: Microsoft SQL Server Management Studio------------------------------Cannot show requested dialog.------------------------------ADDITIONAL INFORMATION:Cannot show requested dialog. (SqlMgmt)------------------------------Failed to create/initialize Agent Alert dialog. (SqlManagerUI)------------------------------Cannot create/initialize Response page. (SqlManagerUI)------------------------------An item with the same key has already been added. (mscorlib)------------------------------BUTTONS:OK------------------------------Please help to resolve the issue.. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-03-12 : 13:52:35
|
That error sounds like a possibly corrupted Management Studio install. Have you tried it from another computer and get the same error? |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-12 : 14:01:13
|
I don't have other server to test.. |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-12 : 14:02:18
|
Can you suggegts any soultion since it is critical for me to resolve it. |
 |
|
robvolk
Most Valuable Yak
15732 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-12 : 18:48:57
|
Deadlocks are happening during midnight and i want trying to see if i can set up deadlocks alerts. |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-03-12 : 19:14:16
|
If you're on SQL 2008, don't waste time with alerts (which tell you nothing other than that a deadlock occurred) or even with profiler or traceflags. Query the system_health extended events session (enabled and running by default) that automatically captures deadlock info.--Gail ShawSQL Server MVP |
 |
|
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2012-03-13 : 01:08:36
|
ThanksCould please provide me the steps to enable the extended events |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2012-03-13 : 05:38:37
|
quote: Query the system_health extended events session (enabled and running by default) that automatically captures deadlock info.
Hence no enabling needs doing. --Gail ShawSQL Server MVP |
 |
|
Next Page
|