Which sp runs when a job fails and we notify operator via email

  • I am not sure that such functionality is publicly facing. I have never seen that exposed.

  • SQL Server Agent should be using Database Mail - which uses sp_send_dbmail. You don't need to intercept anything...instead of checking the box to notify the operators, you just create a new job step with your code.

    In the Advanced properties for the job - on failure redirect to the failure job step. On success - quit the job or go to the next step depending on how your agent job is set up.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Well, yeah, but that's a different approach than he described above. Thing is though, to make it work, you have to master tokens. If you use the above advice, read up on them:

    https://msdn.microsoft.com/en-us/library/ms175575.aspx

    That is the only way you can get information at run time about the involved objects into your email text properly.

  • Ok, thank you.

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply