I have created extended events in SQL server 2012. Everything is working fine. Now I am looking for if any events occur (example :deadlock), it should send mail to given mail id. Is it possible in extended events?
Asked
Active
Viewed 3,617 times
2
-
Was my answer useful? – Thiago Avelino Jun 03 '15 at 23:20
-
In general, there's no way I now of [for now](https://connect.microsoft.com/SQLServer/feedback/details/782941/support-sql-broker-service-to-be-a-target-of-extended-events) to respond to an XEvent directly from T-SQL. However, you can handle/respond to XEvents with the QueryableXEventData class in the .NET Framework. [Here's an example](http://itsalljustelectrons.blogspot.com/2017/01/SQL-Server-Event-Handling-Extended-Events.html) – Dave Mason Jan 06 '17 at 18:28
1 Answers
4
There is a very interesting article about it, basically you need to:
- Enable service broker on the database.
- Create a service broker queue to receive the event notification messages.
- Create a service broker service to deliver event notification messages.
- Create a service broker route to route the event notification message to the service broker queue.
- Create event notification on deadlock event to create messages and send them to the service broker service
Through service broker, a stored procedure can be written that responds to deadlock events. Event notifications allow deadlock graphs to be transformed, stored, and sent wherever they need to go.
- Store the deadlock graph in a table.
- Retrieve the cached plans associated with the deadlock in another table.
- Email the deadlock graph to the DBA team.
You can find the article with the examples on this link: http://sqlmag.com/site-files/sqlmag.com/files/archive/sqlmag.com/content/content/142603/wpd-sql-extevtandnotif-us-sw-01112012_1.pdf
Pages of reference: 9 - 13

Thiago Avelino
- 818
- 6
- 7
-
Hi, I am looking for only configure email alerting system for extended events. Whenever deadlock occur it should sent alert to emailid is it possible with extended events. – Vijay Kumar Jun 04 '15 at 15:18