Setting up some alerting in SQL server 2017 which get dispatched by email to certain DBAs.

Some examples of alerting I am trying to configure would be for Alert number 229 - The EXECUTE permission was denied on the object 'X'

At the moment there is no details included in the email with regards to who had their permission denied - I am wondering, is it possible to include this?

Current notifications look like:

DATE/TIME: 7/2/2018 1:29:59 PM

DESCRIPTION: The EXECUTE permission was denied on the object 'sp_Price', database 'Customisations', schema 'dbo'.


Alerts generated by the SQL Server Agent don't include this information, and you can't add it, unfortunately.

One option would be to set up an Extended Events session to capture the error_reported event and filter by the specific error number. This will allow you to capture additional info such as program name, username, client machine etc.

Log this to a file and use an Agent job to periodically query the file and alert if entries are found.


Login Failures in Extended Events: https://www.mssqltips.com/sqlservertip/3214/use-extended-events-to-get-more-information-about-failed-sql-server-login-attempts/

Extended Events Quickstart Guide: https://docs.microsoft.com/en-us/sql/relational-databases/extended-events/quick-start-extended-events-in-sql-server?view=sql-server-2017

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.