HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Can SQL Agent job notifications be sent to one operator for success and another for failure?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
canoperatorsuccesssqlagentsentnotificationsoneforanother

Problem

We have a requirement that some people are sent notification on success, and other on failure.

But the UI seems to only allow a combination of 1 operator + 1 condition.

So I was wondering if we could do perhaps by transact sql in the MSDB?

Solution

Quite frankly, I would just not use the limited operators facility through the UI and instead:

  • Create a step that only gets reached when the job succeeds, which e-mails person 1



  • Create another step that only gets reached when any step fails, which e-mails person 2



(You may need to modify multiple steps that could potentially fail, such that when they do fail, processing moves immediately to the second step above.)

You can still use operators if you like, just have the steps manually call sp_notify_operator.

Context

StackExchange Database Administrators Q#58634, answer score: 8

Revisions (0)

No revisions yet.