• Okay, here's some code to demonstrate what I'm talking about.

    Save this code as a batch file, and run it:

    for %%a in ("%windir%\*.exe") do SQLCMD -S ServerName -d master -E -Q"set nocount on;select '%%a'" -o "%temp%\output.txt"

    type %temp%\output.txt

    pause

    cls

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

    for %%a in ("%windir%\*.exe") do SQLCMD -S ServerName -d master -E -Q"set nocount on;select '%%a'" >> "%temp%\output.txt"

    type %temp%\output.txt

    pause

    del %temp%\output.txt

    At the first pause, the contents of the output file are displayed. All that is in it is the last *.exe.

    At the second pause, the contents of the output file are again displayed. The prior contents are erased, and all exe files are listed.

    This demonstrates the point the OP was making.

    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