Automatically sends an email when SQL server jobs fail.

Source: Internet
Author: User

Three steps are required:

1. Configure SQL Agent mail.

Http://msdn.microsoft.com/en-us/library/ms186358.aspx

In this step, the profile is configured. The profile email address is the sender of the subsequent email.

2. Create an operator.

Http://msdn.microsoft.com/en-us/library/ms175962%28v= SQL .90%29.aspx

The operator email address is the recipient who sends the email later. If multiple recipients exist, separate the email addresses with semicolons.

3. Set notification in job.

Right-click job-> properties-> notification to send an email when the job fails.

After all the configurations are complete, create a job that will certainly fail to test, such as querying a non-existent table. When the job fails to run, you can query the job history and find the error:

"NOTE: failed to your y' operator name' via email ."

This is because the SQL Agent requires enable mail profile.

Right click SQL Server Agent-> properties-> alert system-> enable checkbox of "enable mail profile". Then restart SQL Server Agent you will receive emails when jobs fail.

All the configuration process can also be achieved with T-SQL, It is very practical to configure a large number of machines Oh ~~ :

Http://www.snapdba.com/2013/04/enabling-and-configuring-database-mail-in-sql-server-using-t-sql/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.