Query Results in job notification

  • I have a job that loads a table every night. I'd like to include the row count in my notification when the job completes. I added a step to query the database and in advanced options said to include the output in the history for the job. However, my notification is not showing the row count.

    Any advice?

  • Unfortunately job notifications will not show such information. You need to look at the job history to see such information.

    Cheers,

    - Mark


    Cheers,
    - Mark

  • You can do so by either adding an additional step to the job or within the same step to query the tables to get the count. Then send the results using xp_sendmail. I have used the above approach in many instances and works well. Here is an example.

    ********************************************

    exec master.dbo.xp_sendmail

    @recipients= 'someone@company.com',

    @subject='Record Counts from the XYZ Load',

    @QUERY = 'Select Count(*) from dbo.LoadedTable where Load_date = "Today"',

    @MESSAGE = 'Here is the Count from the Data Load'

    ============================================

    If you have more than one line of queries to execute, wrap them into a Sproc and exeute the same from the xp_sendmail.

    Have a good one

    -Sravan

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

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