Not creating an empty file when zero rows returned

  • SQL Server 2000 DTS:  Want to do one of 2 things:  1) not produce a destination file at all if there are zero rows qualified out of the source query, or 2) delete the file after it is produced IF it's an empty file.  Any ideas/solutions are appreciated.

  • You can always do the crude and some would say klugy thing of a execsql step that says:

    IF NOT EXISTS( select 1 from table where condition) RAISERROR...

    and use the success path from that DTS step to the export routine.

    As for me, I tend to do the export inside a SQL proc and wrap it with that condition. (using xp_cmdshell to BCP the data)

     

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

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