you have to add a step beforehand where you check the count of the sp
if the count = 0 end
if it's > 0 produce the file
You can store this in a global variable
âI sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
http://sqlservercode.blogspot.com/