SQL Mail Configuration

  • Hi,

    I have configured DB mail for running job. I am getting daily mail whenever job is running in both cases either success or fail.

    Whenever job is failed , in the mail I am not able to find what is the reason for job failure. For this situation I have to go the particular server and find the failure job and chack manually why it is failed.

    My question is , Instead of checking manually , Is there anyway to get details in the mail itself.

    Thanks in advance..

  • Hi,

    Create a SP using the below link

    http://www.sqlservercentral.com/articles/SQL+Server+Agent/67726/

    then use the sp_send_dbmail to send the job history when the job fails.

    as below:

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'DBMail_BAP',-- provide your profile name

    @execute_query_database = 'msdb',

    @recipients = 'jxxxxx@corp.com',

    @query = 'EXEC dbo.pr_GetStepFailureData ''provideyourJobname''' ,

    @subject = 'xxxx job has been failed',

    @exclude_query_output = 1,

    @append_query_error = 1

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply