sql-server-2008-r2sql-server-agentsql-server-job

SQL Server - send email task on job failure


we have a job that runs several times a day making incremental backups.

We have added a step 'Send email on Job failure' that uses T-SQL to send an email to the admins team if the first step (Incremental backup) has failed.

Unfortunately we must have configured the Advanced options in the second step incorrectly, as we are getting an email even when the first step has succeeded.

The email is being sent successfully by the second step.

We have configured the options for the first step as follows:

We have configured the options for the second step as below:

Now, when the task, step 1 succeeds, we don't expect to receive an email. When step 1 fails we expect an email.

So what are we doing wrong?


Solution

  • Not sure if what you have written is truly the step, if it is then this is the reason you are always getting an email.

    Step 1 = Fail => Go To step 2. Send Email

    Step 1 = Success => Go To step 2. Send Email

    You should have the Notifications "tab" configured to sent an email "When Job Fails"