Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 E-mail notification for job success and fail

Author  Topic 

chbala85
Starting Member

49 Posts

Posted - 2013-06-18 : 00:34:09
Hi Guys,

Am i using SQL Server 2005 and I am writing a SQL Server Agent Job. In my Job, there is one step and in step I will execute a store procedure.
My question is, i want send email nitificaton if job fail and success both cases also if job success(duraion,runtime,jobname),if job fail(jobname ,error message).

Please help me it's urgent works.

Thanks,
krsh.

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-06-18 : 00:44:24
I don't know much about Agent Jobs.. This link might help you to
get the information regarding agent jobs
http://www.mssqltips.com/sqlservertip/1752/analyzing-sql-agent-job-and-job-step-history-in-sql-server/


--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-18 : 00:46:03
You can configure in sql server agent job itself to send mail as a notification.

But if you want to customize it to send specific details you should add a new step to send the mail using sp_send_dbmail. For the main step (stored procedure) on failure make it goto the new step created.
Similraly create another step for success mail.
Create a control table which will log results of procedure run. In the email steps read values from the table (errormessage,etc for failure and duration etc for success) and then pass the results to sp_send_dbmail

http://msdn.microsoft.com/en-us/library/ms190307.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -