Sending Job Failed Information Through E-Mail Using T-SQL


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        =''




Comments

Popular posts from this blog

Index Clean-Up Scripts

forgot sa password and no logins are added

The SQL Server DBA’s Guide to Teradata