join the MSSQLTips community

Today's Site Sponsor


 

Find performance issues related to Analysis Services memory limits.
 


How to setup SQL Server alerts and email operator notifications
Written By: David Bird -- 6/19/2008 -- 2 comments -- printer friendly -- become a member



SQL Server monitoring made easy

        Win SQL Books  -----  SharePoint Tips  -----  Live Webcast - SQL Backup Mistakes  -----  Bookmark and Share        

Problem
Setting up an alert to e-mail an operator with a message is a multiple step process. You can setup database mail, define an operator and an alert, but still no e-mail is being sent. So how do you send an alert to an operator?

Solution

Note: This solution involves restarting SQL Agent.

Database Mail

First setup database mail with a profile named SQLAlerts. The profile can be named anything but in these instructions, the profile name SQLAlerts is referenced. If you wish to use a different profile name just substitute accordingly. For procedures in setting up database mail, see this post.

Define Operator

Connect to the instance using Microsoft SQL Management Studio

Double Click SQL Server Agent

Right Click on Operators and select New Operator


Specify an operator Name, E-mail name, and click OK

Setup SQL Agent Settings

Note: This step is often overlooked when creating an alert for the first time. SQL Agent must be setup correctly for operators to receive an alert e-mail.

Right Click SQL Server Agent > select Properties

Select Alert System in the left pane

  • Checkmark > Enable mail profile
  • Verify Mail system: Database Mail
  • Verify Mail Profile: SQLAlerts
  • Checkmark > Include body of e-mail in the notification message
  • Click OK.

Restart SQL Agent to activate settings.

Warning: Restarting SQL Agent will cancel any executing jobs.

Define Alert

This sample alert will send an email when TEMPDB database gets larger than 0 KB. This setting is set zero so the alert can be tested. Once verified, you will need to update its settings to a reasonable amount or disable it.

Right Click Alerts and select New Alert

On the General pane specify

  • Name: TEMPDB Growing
  • Type: SQL Server performance condition alert
  • Object: SQLServer:Databases
  • Counter: Data File(s) (KB)
  • Instance: tempdb
  • Alert if counter: rises above
  • Value: 0

Click Response in left pane

  • Checkmark > Notify operators
  • Checkmark > E-mail for the operator

Click Options in left pane

  • Checkmark > Include alert error text in E-mail
  • Delay between response: 2 minutes

Click OK

Verify Alert is Working

The operator should receive an e-mail if not see the troubleshooting section.

Open the Alert. Click History in the left pane.

The fields are updated when the alert is triggered.

Stop the Test

To stop the Alert from being sent every two minutes, you have two options disable the alert or provide a more appropriate size and response times.

To disable alert

  • Click General in left pane and remove the checkmark from Enable and click OK
  • OR
  • Right click on Alert name and select Disable

To change the settings

  • Click General in left pane
  • Change value to value larger than existing TEMPDB database file save. The current file size is included in the e-mailed alert.
  • Click Options in left pane
  • Change response to 720 minutes which is 12 hours
  • Click OK

Troubleshooting

If the operator does not receive an e-mail

  • Test database mail by sending a test e-mail to the operator's e-mail address.
  • Make sure you restarted SQL Agent and it is running.

Next Steps

  • Modify the alert to execute a job that captures all current connections using sp_who2 .
  • Create alerts for other criteria you wished to monitor.
  • Using SQL Server Manager Studio, you can script the alert so you can easily create it in other instances. See this tip on how to create scripts.
Readers Who Read This Tip Also Read Comment or Ask Questions About This Tip Twitter This Tip!


 
SQL Server monitoring made easy SQL Response Screenshot
Use SQL Response to monitor the health and activity of all your SQL Servers in just one intuitive interface.

Download a free trial of SQL Response now.

"Keeping an eye on our many SQL Server instances is much easier with SQL Response. I now have one place to look to see if my production servers are healthy and what routine maintenance is required."
Mike Lile DBA, K2B, Inc.

 
SQL Response logo
Red Gate Software - ingeniously simple tools

 

 



DB Nitro - SQL Nitro

SQL Nitro sits between SQL Server & its clients, optimizing the normally inefficient TDS protocol. Optimize TDS & compress the data up to 80%, reduce SQL bandwidth by 50%, & improve response times over 65%!

Download now!

More SQL Server Tools
SQL Nitro

SQL Data Generator

SQL comparison toolset

SQL secure

SQL diagnostic manager


Sponsor Information
Free SQL Server performance monitoring dashboard – Idera SQL check

Try Red Gate SQL Multi Script: Execute multiple scripts against multiple SQL Servers with one click!

SQL Server Health Check - Innovative solutions at affordable prices. DBA consulting services.

Stop here to prepare for your next SQL Server interview!

Top 10 SQL Server Backup Mistakes and How to Avoid Them web cast by Greg Robidoux - February 10, 2010

Become a member of the MSSQLTips community

Just launched – MSSharePointTips.com...

Free Whitepaper - Streamline Backup & Recovery with LiteSpeed for SQL Server and LiteSpeed Engine for Oracle



Copyright (c) 2006-2010 Edgewood Solutions, LLC All rights reserved
privacy statement | disclaimer | copyright | advertise | write for mssqltips | feedback | about
Some names and products listed are the registered trademarks of their respective owners.