Home > SQL Server Tips > > Alerting capabilities in SQL Server 2005
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 


Alerting capabilities in SQL Server 2005


Jeremy Kadlec, Edgewood Solutions
08.31.2006
Rating: -4.33- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Introduction

Native alerts were valuable in SQL Server 2000, but at the same time they were unreliable in many cases due to SQL Server Mail's dependency on MAPI with Outlook. Many 'work-arounds' were created to improve the inherent functionality based on individual needs. SQL Server 2005 has alleviated this issue with the introduction of Database Mail. Thus far, this solution seems to meet industry needs for an SMTP based email system and has enabled the native SQL Server alerting capabilities to shine. In this tip we will outline the prerequisites for alerts, setup options and then highlight valuable alerts you'll want.

SQL Server 2005 alerts prerequisites

SQL Server 2005 Alerts are dependent on a few core pieces of infrastructure to operate properly. These items include:

ID Directions Screen Shot\Code
1 Enable the database mail stored procedures by executing the following code in a query window in SQL Server 2005 Management Studio.
2 Setup Database Mail with accounts to associate with an Operator and to support receiving alerts.

Below are the directions to start the Database Mail Configuration Wizard:

  1. Open the SQL Server 2005 Management Studio
  2. In the Object Explorer, expand the 'Management' folder
  3. Right click on the 'Database Mail' option
  4. Select the 'Configure Database Mail' option
[IMAGE]
3 Setup Operators to receive alerts.

Below are the directions to setup SQL Server Operators:

  1. Open the SQL Server 2005 Management Studio
  2. In the Object Explorer, expand the 'SQL Server Agent' option
  3. Right click on the 'Operators' folder
  4. Select the 'New Operator' option
  5. Complete the interface on the right for the operator
[IMAGE]
4 Configure SQL Server Agent to use the mail session as well as have a fail-safe operator.

Below are the directions to configure SQL Server Agent:

  1. Open the SQL Server 2005 Management Studio
  2. In the Object Explorer, right click on the 'SQL Server Agent' option
  3. Select the 'Properties' option
  4. Select the 'Alert System' tab
  5. Complete the interface on the right
[IMAGE]

SQL Server 2005 alerts setup

SQL Server has two means to setup native alerts. The first is with SQL Server 2005 Management Studio and the second is via a set of system stored procedures. Below outlines examples of each option:

ID Option Screen ...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
SQL Server Database Modeling and Design
Optimizing SQL Server indexes –- even when they're not your indexes
Top tips and tricks for SQL Server database development
Managing the development lifecycle with Visual Studio Team System 2008
A first look at Visual Studio Team System 2008 Database Edition
Testing transaction log autogrowth behavior in SQL Server
Top 10 SQL Server Tips of 2008
Tutorial: SQL Server indexing tips to improve performance
Tutorial: Learn SQL Server basics from A-Z
SQL Server database design disasters: How it all starts
Can you shrink your SQL Server database to death?

Microsoft SQL Server Installation
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Migrating down to Standard Edition
What's new for installation with SQL Server 2008?
Creating fault-tolerant SQL Server installations
SQL Server consolidation: Why it's an optimization technique
SSIS error message due to installation problem on SQL Server 2005
Get SQL Server log shipping functionality without Enterprise Edition
Tutorial: Migrating to SANs from local SQL Server disk storage
SQL Server tools don't appear in menu after SQL Server 2005 install
Troubleshoot SQL Server 2005 SP2 installation error
Microsoft SQL Server Installation Research

Microsoft SQL Server Performance Monitoring and Tuning
SQL Server Mailbag: CALs, witnesses and unwanted changes
SQL Server Mailbag: Data restoration and DB property management
Working with IntelliSense in SQL Server 2008 Management Studio
SQL Server Mailbag: Stored procedures, triggers and SSRS reports
Troubleshooting Distributed Transaction Coordinator errors in SQL Server
Clearing the Windows page file and its effect on server performance
Optimizing SQL Server indexes –- even when they're not your indexes
Performance implications of transaction log autogrowth in SQL Server
The short course on how SQL Server really works
Determining the source of full transaction logs in SQL Server

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
binary tree  (SearchSQLServer.com)
block  (SearchSQLServer.com)
data structure  (SearchSQLServer.com)
DDBMS  (SearchSQLServer.com)
entity-relationship model  (SearchSQLServer.com)
initial extent  (SearchSQLServer.com)
primary key  (SearchSQLServer.com)
segment  (SearchSQLServer.com)
tablespace  (SearchSQLServer.com)
view  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


shot/code

1a SQL Server 2005 Management Studio Interface to setup alerts

General Tab – Configure the name, severity, etc on this interface

Below are the directions to configure SQL Server 2005 alerts:

  1. Open the SQL Server 2000 Management Studio
  2. In the Object Explorer, open the 'SQL Server Agent' option
  3. Right click on the 'Alerts' folder
  4. Select the 'New Alert' option
  5. Complete the interface on the right
[IMAGE]
1b Response Tab – Select the operators to notify [IMAGE]
1c Options Tab – Indicate the options when the text will be included and the delayed response parameter [IMAGE]
2 Two SQL Server 2005 system stored procedures are responsible for creating alerts and notifying operators.

These procedures are:

  • sp_add_alert
  • sp_add_notification

    Valuable SQL Server 2005 Alerts

    Below are three basic approaches to building a set of needed SQL Server 2005 alerts, since none are created by default:

    ID Approach Sample code
    1 Category

    For example, -- the Severity Level is considered a Fatal Error for levels 19 to 25.
    2 Keyword

    For example, 'Primary Filegroup is full' when the database can no longer allocate space for the database.
    3 Error Number

    For example, error 9100 related to index corruption.

    Duplicating the alerts

    Once you have all of the alerts that you want on one specific SQL Server, they can be scripted out and created on another SQL Server. This can be accomplished by the following steps:

    • Open the SQL Server 2005 Management Studio
    • In the Object Explorer, open the 'SQL Server Agent' option
    • Expand the 'Alerts' folder
    • Select any alert that you want to script out
    • Right click on the alert and select the following options
      • 'Script Alert as'
      • 'CREATE To'
      • 'New Query Editor Window'
    • Connect to the needed SQL Server, then Copy the code from the original window and paste the code into the correct SQL Server's query window
    Conclusion

    SQL Server 2005's alerting capabilities are expected to meet the much desired features of the SQL Server community. Based on your application needs configure your alerts to be the first line of defense in if SQL Server has an issue. Do not overlook this simple yet valuable means to obtain near real time alerts.

    About the author: Jeremy Kadlec is the Principal Database Engineer at Edgewood Solutions, a technology services company delivering professional services and product solutions for Microsoft SQL Server. He has authored numerous articles and delivers frequent presentations at regional SQL Server Users Groups and nationally at SQL PASS. He is the author of the Rational Guide to IT Project Management. Jeremy is also the SearchSQLServer.com Performance Tuning expert. Ask him a question here.


    Rate this Tip
    To rate tips, you must be a member of SearchSQLServer.com.
    Register now to start rating these tips. Log in if you are already a member.




    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • SQL Server Development - .NET, C#, T-SQL, Visual Basic
    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts