Don't Export if no result in Distribution/Scheduler

SOLVED

Hello

I have a scheduled job that runs and exports the results of the view to a network share. Is there a way in the Job properties to suppress the export of the view to a file if there's no data? It will export a file and append "no data" to the blank file.

Thank You

Andrew

  • +1
    verified answer

    Hi Andrew, 

    You need to add an entry on the Conditions tab of the Scheduled Job.

    For example, if I was looking for a Daily Customer Returns report, but wanted to suppress a blank one, I would add the following as the condition:

    (

    SELECT COUNT(*)

    FROM TEST.SRETURN

    WHERE RTNDAT_0 = DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)

    ) > 0

    The above then specifies that there must be at least one record before the report can be either be exported to a network share or emailed.

    The SELECT statement in the brackets would need to be amended to suit your data model criteria.

    Best regards,

    Nick

  • 0 in reply to Nick Brown

    Thank you Nick. I think I can work with this to get it to work