Email Notification for each steps in MS sql server

Nizam Muhammed 1 Reputation point
2022-11-08T16:06:01.43+00:00

Hi Everybody,

i have triggered a job with multiple steps in sql server Agent

is it possible to create email notification for each steps in the job in MS sql server Agent if the steps fail/success ?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
{count} votes

3 answers

Sort by: Most helpful
  1. jerryritcey 1 Reputation point
    2022-11-08T17:03:18.343+00:00

    I can only think of two ways to do this.

    Method A
    Set up a step after each existing step in the job to run sp_send_dbmail to your chosen address. Little clumsy, less complicated.

    Method B

    1. Seperate all your steps into their own jobs, using the existing email notification options built in. At the end of each step, update a table with a step completed indication
    2. At the start of each step after step , check the step completed table to see if this job should run if the prior step worked, or quit since the prior step did not finish.

    Method A is simpler from a perspective of keeping job history in one place.

    0 comments No comments

  2. Olaf Helper 41,001 Reputation points
    2022-11-09T06:34:07.24+00:00

    is it possible to create email notification for each steps in the job in MS sql server Agent if the steps fail/success ?

    Not with build-in functions.
    You can add additional steps to send email using sp_send_dbmail (Transact-SQL)

    0 comments No comments

  3. YufeiShao-msft 7,061 Reputation points
    2022-11-09T09:32:32.797+00:00

    Hi @Nizam Muhammed ,

    You can use sp_send_dbmail, for each step set a notification

    https://blog.sqlbackupandftp.com/how-to-set-up-sql-server-email-job-notifications#:~:text=To%20set%20up%20an%20email%20notification%20for%20an,that%20is%20when%20you%20want%20to%20be%20alerted.

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments