• Jeff Moden (6/14/2009)


    You've added a line of code the OP didn't have in the original problem and that new line is the one responsible for the incorrect operation.

    echo %date% %time% > "%temp%\output.txt

    You've neglected to use ">>" in that line of code and that's what resets file. 😉

    Correct, I reset the file between the runs, to demonstrate the effects of the two different methods. If the OP wants the file reset between runs, then use this line. If not, then get rid of it.

    But the point was that with using the "-o" in the first part, the file is reset for every file being processed. Which is the behavior that the OP was trying to get rid of.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2