How to Send Email to Multiple Email accounts From SQL Server Agent if Job Fails - DBA Tutorial

In this video you will learn how to send email to multiple recipients (email addresses) if SQL Server Agent Job fails. It demonstrates using couple of methods.
1- Send email to multiple accounts (recipients) using sp_send_dbmail store procedure
2- Send email to multiple accounts (recipients) using configured Operator (SQL Server Agent Operator)


Scripts 1:

--How to send email to multiple email accounts from SQL Server Agent Job if fails_sp_send_dbmail
EXEC msdb.dbo.sp_send_dbmail
--Your profile name
    @profile_name = 'Techbrothers',
 --Your multiple recipients
    @recipients = 'email1@gmail.com;email2@yahoo.com',
    @body = 'Job Failed Please check ASAP',
    @subject = 'Job Failed on Production System' 

Script 2: 
--How to send email to multiple email accounts from SQL Server Agent Job if fails_addOperator
USE [msdb]
GO

/****** Object:  Operator [DBA]    Script Date: 4/13/2015 8:23:14 PM ******/
EXEC msdb.dbo.sp_add_operator @name=N'DBA', 
  @enabled=1, 
  @weekday_pager_start_time=80000, 
  @weekday_pager_end_time=235900, 
  @saturday_pager_start_time=90000, 
  @saturday_pager_end_time=180000, 
  @sunday_pager_start_time=90000, 
  @sunday_pager_end_time=180000, 
  @pager_days=62, 
  @email_address=N'email1@gmail.com;Email2@yahoo.com', 
  @category_name=N'[Uncategorized]'
GO


Script 3:
--How to send email to multiple email accounts from SQL Server Agent Job if fails_updateOperator

  --How to look at Operator information
  select * from sysoperators
--How to update operator to send email to multiple recipients

EXECUTE msdb.dbo.sp_update_operator
  @name = N'DBA',
  @email_address = N'Email1@gmail.com;Email2@gmail.com'



Send Email to Multiple Email accounts From SQL Server Agent if Job Fails - DBA Tutorial

12 comments:

  1. Email checker or atomic email verifier software is all the same, and they go hand to hand with email marketing if you are talking about a large scale. To get the best out of your email marketing, you need to mix those two together to get the best flavours.

    ReplyDelete
  2. I am a new user of this site so here i saw multiple articles and posts posted by this site,I curious more interest in some of them hope you will give more information on this topics in your next articles. hotmail.com

    ReplyDelete
  3. Thanks for picking out the time to discuss this, I feel great about it and love studying more on this topic. It is extremely helpful for me. Thanks for such a valuable help again. saiba como acessar o site www.hotmail.com entrar

    ReplyDelete
  4. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. entrar no hotmail

    ReplyDelete
  5. If you've got ever cursed your fax machine for its numerous paper jams or premature toner outages, sending e mail fax documents may additionally offer you with a simple answer for those commonplace ills.can you fax documents online

    ReplyDelete
  6. I am definitely enjoying your website. You definitely have some great insight and great stories. how to send a fax from my phone

    ReplyDelete
  7. This is why, once one spammer gets your email, you might begin receiving spam from all over the place. People are buying and selling your email address. email extractor from website

    ReplyDelete
  8. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this..........send fax from email
    send fax from email

    ReplyDelete
  9. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. send fax from phone

    ReplyDelete
  10. How about we perceive how every part of room furniture needs explicit consideration when you go out for shopping! CBT Bulk Email Sender Software

    ReplyDelete
  11. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. send and receive fax android

    ReplyDelete
  12. Gathering focused on URL's and the addresses that originate from them is the most ideal approach to get delivers that are valuable to your specific circumstance. CBT Mass Email Sender

    ReplyDelete