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
 Email notification store procedure

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2011-08-22 : 09:01:07
I would like to create a store procedure.

If the timing on the job run is more than 1 minute, send email notification to my email address.

Can this possible to be done?

I have tried on the send email notification part, but I have no idea on the logic part.

If time > 1 minute
send email notification

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-22 : 09:17:14
you can do it
make use of msbd.dbo.sysjobhistory to get running job info and use sp_send_dbmail to sent notification mail
please look into books online for the syntax an usage.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2011-08-22 : 10:07:14
Books online?

i would just like to know how to apply on the logic part.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-22 : 12:23:08
see this to get if job is executing

http://www.sqlservercentral.com/articles/Administration/howtofindthatjobisrunning/2071/

then use run_date < DATEADD(mi,-1,GETDATE())
to find if it has ran over 1 min



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -