10 Steps Using SQL Server Agent to Create Email Alert

In this article, we’ll go over how to notify email users when a SQL job fails. Configuration is done to alert the user to handle failed jobs. We’ll go over how to set up SQL Server Agent, Database Mail, Email profile, SMTP configuration, Operator to send email, and notification.

We are aware that in order to execute a series of operations automatically on the SQL server, jobs must be configured. A configured task will be executed once or more times and its success or failure will be tracked. Daily, weekly, monthly, and quarterly reports, automatic emails, newsletters, writing log files, and audit logs to be sent automatically on local or remote locations are a few examples of SQL jobs.

How to Setup Email Notification

To configure email notification of SQL job failure, follow these instructions:

1. Under Management, Configure Database Main. Right click on Database Mail and select the first option (Configure Database Mail)

2. Create a new profile, so select the first option and click on Next.

3. Click the Add button to add SMTP settings after writing the profile name and description.

4. For this example, I will test using GMail SMTP configuration.

5. When profile is ready then click Next to proceed.

6. Set up system-level options like the retry mechanism, the size of any attached files, and the permitted and prohibited extension lists. Select Next. Simply choose Finish on the next screen, which displays all of your account’s details. Your entire configuration has been built successfully.

7. Create an Operator. Now we have to make an operator to whom you want to send email when the SQL job is failed -> Expand SQL Server agent -> Right-click on Operators and select new operator

8. Enter your Operator name and the recipient’s email address on the following screen. Simply separate each email address with a ‘;’ if you want to send an email to more than one recipient.

The operator is now ready to send emails after clicking OK.

9. Create a new SQL job

10. Select Notifications, check Email, and then choose the operator that we previously defined.

When jobs go wrong, emailing is helpful. Afterward, select OK.

Summary

This article demonstrates how to configure email notifications for failed SQL jobs step-by-step. To take the immediate, necessary actions, these notifications are absolutely necessary. Cheers to configuration!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *