sql - Alert when stored procedure fails -
is possible have sql server (2008)
send email alert if stored procedure
fails any reason?
i can quite sql job can't see options within programmability
area or properties of stored procedure
itself. stored procedure
triggered via application on demand. have looked @ doing other application adds many layers of complication-i hoping sql server
had me covered on this!?
i have searched not found same question.
thanks.
high level overview of how can this..
1.modify stored procs return 1 in case of failure , log table.this has weakness because some failures wont caught
2.once information logged table,then sending email easy using sp_send_dbmail.
exec msdb.dbo.sp_send_dbmail @profile_name = 'adventure works administrator', @recipients = 'yourfriend@adventure-works.com', @query = 'select count(*) adventureworks2012.production.workorder duedate > ''2004-04-30'' , datediff(dd, ''2004-04-30'', duedate) < 2' , @subject = 'stored procedures failures'
if want send email,i use above approach instead of sending email every failure.since logged data table,i can run sql job every 1 hour or depending on frequency need
Comments
Post a Comment