This script is useful to send an email when there is a job failure.
This script is useful to send an email when there is a job failure.
DECLARE @SN NVARCHAR(100), @MSG NVARCHAR(100), @SQL NVARCHAR(250) SET @SN = @@SERVERNAME SET @MSG = @SN + 'Your Message' SET @SQL = 'JobName'+ @SN + ' failed - please review this job' EXEC msdb.dbo.sp_send_dbmail @profile_name ='ProfileName', @recipients ='recipient@gmail.com;recipient1@gmail.com ', @copy_recipients ='', @blind_copy_recipients ='', @subject =@MSG, @body =@SQL, @body_format ='HTML', @importance ='HIGH', @sensitivity ='NORMAL', @file_attachments =''