SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 E-mail notification for job success and fail
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chbala85
Starting Member

49 Posts

Posted - 06/18/2013 :  00:34:09  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2218 Posts

Posted - 06/18/2013 :  00:44:24  Show Profile  Reply with Quote
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

Edited by - bandi on 06/18/2013 00:45:55
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 06/18/2013 :  00:46:03  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000