SQL Server Performance

how to text file append?

Discussion in 'SQL Server 2005 General DBA Questions' started by mpolaiah, Aug 5, 2009.

  1. mpolaiah New Member

    Hello,

    I have several sql scripts to be executed on a set schedule, with the output directed to a text file. If the schedule triggers this process daily, is it possible to append each days output to the same output file? I've researched the osql switches and various online sources...nothing really covers this.

    This is done (relatively) easily with .vbs, but so far it looks tougher with TSQL.

    Many thanks to all who respond!
  2. preethi Member

    You said sql scripts executed on a set of schedule. Is that on sql jobs?
    If you talk about sql jobs you can add a OS command as another scriptt to append the output.
    I use something like this from command prompt: Ths is not for scheduled tasks, but I dont see why it cannot be added.
    for %f in (path1*.sql, path2*.sql) do sqlcmd -S <ServerInstance> -U <Username> -P <Password> -d <Database> -i %f >>output.txt

Share This Page