SlideShare a Scribd company logo
​SQL Server Agent Alerts 
 
                             ​     source­ ​ ​https://msdn.microsoft.com/en­us/ms180982.aspx       
Being a database administrator has many responsibilities, and knowing what is 
happening on your SQL Server is one of them. Being proactive and alerted to errors is 
one of the traits that makes someone a great DBA. And I’m not just talking about things 
failing, which is what most people think of being alerted about; you can also be alerted 
about performance problems. Within SQL Server you have the ability to create SQL 
Server Agent Alerts (which I’ll just call ‘alerts’ from now on), and this is easily 
accomplished using the GUI or T­SQL. 
Configuring SQL Server Agent Alerts 
To use alerts you must have Database Mail and a SQL Agent Operator configured. Most 
SQL instances I have come across already have Database Mail configured for job 
failure notifications. 
A lesser­known task is configuring the Operator. You can create the Operator using 
SSMS or T­SQL. Within SSMS expand SQL Server Agent, right click on Operator and 
chose New Operator. You will have a new dialog box open where you can give the 
operator a name and specify the email address to notify. I prefer to use a distribution 
group for the email notifications. Most companies have more than one person 
responsible for the SQL environment and if you specify a distribution group then the 
entire team can be notified of the alerts. Using distribution groups also makes it much 
easier to add or remove people from the alerts​. 
 
 
 
                   ​ Below is an example screenshot of the New Operator dialog: 
 
I prefer using T­SQL so I can make sure that creating the Operator is part of a server build 
template. Example code for creating the above Operator is as follows: 
EXEC​ msdb​.​dbo​.​sp_add_operator​ @name​ ​=​ ​N'SQL_Alerts'​,  
 ​@enabled​ ​=​ 1​,  
 ​@email_address​ ​=​ ​N'sql_alerts@mydomain.com'​; 
Once you have Database Mail and the Operator configured you can create the alerts and 
assign them to the Operator. 
If using SSMS, you can expand SQL Server Agent and then Alerts. By default, no alerts are 
created. If you right click and chose New Alert, you will get a screen similar to the figure 
below: 
 
You will notice that under Severity, there are 25 severity codes. Just like it sounds, error level 
severity describes how important the error is. Severity 10 is informational while 19­25 are fatal 
and you will want to be notified when those errors arise. If a severity 23 error arose, for 
example, then you most likely have corruption in one of your databases. These fatal errors 
can all impact the performance of your server, which in turn impacts the customer experience. 
 
You can create each of the Alerts by specifying the name and selecting the severity. For Error 
825 you would select Error and type the number. As with the Operator, I prefer to use T­SQL. 
If I can easily script a process then it is much easier to reuse and include as part of a server 
build. 
Below you will find the script that I have used on my SQL Server 2014 Enterprise Edition. This 
script creates each of the alerts and adds a notification for the alert to the Operator 
SQL_Alerts. 
EXEC msdb.dbo.sp_add_alert @name = N'Severity 19 Error',
@message_id = 0, @severity = 19, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 19 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Severity 20 Error',
@message_id = 0, @severity = 20, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 20 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name=N'Severity 21 Error',
@message_id = 0, @severity = 21, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 21 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Severity 22 Error',
@message_id = 0, @severity = 22, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 22 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Severity 23 Error',
@message_id = 0, @severity = 23, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 23 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Severity 24 Error',
@message_id = 0, @severity = 24, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 24 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Severity 25 Error',
@message_id = 0, @severity = 25, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Severity 25 Error',
@operator_name = N'SQL_Alerts', @notification_method = 1;
EXEC msdb.dbo.sp_add_alert @name = N'Error 825',
@message_id = 825, @severity = 0, @include_event_description_in = 0;
EXEC msdb.dbo.sp_add_notification @alert_name = N'Error 825',
@operator_name = N'SQL_Alerts', @notification_method = 1;
If you have followed along, you would have database mail configured, created an Operator to 
email you or a distribution group about potential errors, and SQL Server Agent Alerts 
configured for Severity 19 – 25 and error 825. 
This is great. Any time one of those alerts are triggered an email will be sent to your team. In 
addition to event alerts, alerts can be configured for a performance condition, To find the SQL 
Server performance condition alerts, in the new alert dialog box, click the drop down box for 
Type. There you will see SQL Server performance condition alert listed. Once you chose that 
option you can browse the types of objects you can configure a performance condition alert 
on. 
 

More Related Content

PPTX
Recover Deleted Outlook Emails
PPT
Mac document recovery
PPTX
Market Feasibility
PDF
Market research on telecom GSM service ppt on
PDF
Business intelligence implementation case study
PDF
Always on availability group
PDF
SSIS VISUAL STUDIO 2013 & SQL SERVER 2014
PDF
SQL Server 2014 Installation
Recover Deleted Outlook Emails
Mac document recovery
Market Feasibility
Market research on telecom GSM service ppt on
Business intelligence implementation case study
Always on availability group
SSIS VISUAL STUDIO 2013 & SQL SERVER 2014
SQL Server 2014 Installation

Viewers also liked (16)

PDF
Project Management
PPTX
Case Study on Business Intelliegnce
PDF
Business intelligence project
PPT
Business Intelligence for kids (example project)
PDF
Maintanance plan
PDF
Restoring the database
PDF
database backup
PDF
Business Analysis and Reporting
PDF
Developing Business Plan
PDF
Market Research Report
PDF
DATABASE MIRRORING SQL SERVER 2014
PDF
Youtube analytics SAMPLE PROJECT
DOCX
Scorecard & Dashboards
PDF
Wedding invitation
PDF
Configuring & Managing Databases
PDF
Case Study on Business Intelligence
Project Management
Case Study on Business Intelliegnce
Business intelligence project
Business Intelligence for kids (example project)
Maintanance plan
Restoring the database
database backup
Business Analysis and Reporting
Developing Business Plan
Market Research Report
DATABASE MIRRORING SQL SERVER 2014
Youtube analytics SAMPLE PROJECT
Scorecard & Dashboards
Wedding invitation
Configuring & Managing Databases
Case Study on Business Intelligence
Ad

Similar to Sql server agent alerts (6)

PDF
Make sql server to talk you
PPTX
SQL Phone Home: Teaching Your SQL Servers to Call for Help
PPTX
Sql server lesson9
PDF
Oracle alert
PDF
Get More Out of Your PeopleSoft Applications Using Tools that You May Not Eve...
PDF
MSSQL Server - Automation
Make sql server to talk you
SQL Phone Home: Teaching Your SQL Servers to Call for Help
Sql server lesson9
Oracle alert
Get More Out of Your PeopleSoft Applications Using Tools that You May Not Eve...
MSSQL Server - Automation
Ad

Recently uploaded (20)

PDF
Data Engineering Interview Questions & Answers Batch Processing (Spark, Hadoo...
PDF
Microsoft 365 products and services descrption
PPTX
A Complete Guide to Streamlining Business Processes
PDF
Transcultural that can help you someday.
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Pilar Kemerdekaan dan Identi Bangsa.pptx
PDF
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
PDF
Introduction to Data Science and Data Analysis
PPT
Predictive modeling basics in data cleaning process
PPTX
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
annual-report-2024-2025 original latest.
PDF
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPTX
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
PPTX
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
PDF
Navigating the Thai Supplements Landscape.pdf
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PDF
Global Data and Analytics Market Outlook Report
PPT
ISS -ESG Data flows What is ESG and HowHow
Data Engineering Interview Questions & Answers Batch Processing (Spark, Hadoo...
Microsoft 365 products and services descrption
A Complete Guide to Streamlining Business Processes
Transcultural that can help you someday.
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Pilar Kemerdekaan dan Identi Bangsa.pptx
REAL ILLUMINATI AGENT IN KAMPALA UGANDA CALL ON+256765750853/0705037305
Introduction to Data Science and Data Analysis
Predictive modeling basics in data cleaning process
Copy of 16 Timeline & Flowchart Templates – HubSpot.pptx
IBA_Chapter_11_Slides_Final_Accessible.pptx
annual-report-2024-2025 original latest.
Data Engineering Interview Questions & Answers Cloud Data Stacks (AWS, Azure,...
STERILIZATION AND DISINFECTION-1.ppthhhbx
(Ali Hamza) Roll No: (F24-BSCS-1103).pptx
sac 451hinhgsgshssjsjsjheegdggeegegdggddgeg.pptx
Navigating the Thai Supplements Landscape.pdf
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Global Data and Analytics Market Outlook Report
ISS -ESG Data flows What is ESG and HowHow

Sql server agent alerts