Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 OSQL

Author  Topic 

munkdogg
Yak Posting Veteran

53 Posts

Posted - 2008-03-11 : 15:48:02
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!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-11 : 19:20:22
You can do this via >>.

osql -iC:\SomeScript.sql -Sserver1 -E >>C:\SomeOutputFile.txt

So it's not a switch of osql but rather a DOS option to say to redirect the output to a file. > will create a new file or overwrite, >> appends.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

munkdogg
Yak Posting Veteran

53 Posts

Posted - 2008-03-12 : 09:03:32
Excellent! Thanks so much, I knew it had to be something simple like this :-)

quote:
Originally posted by tkizer

You can do this via >>.

osql -iC:\SomeScript.sql -Sserver1 -E >>C:\SomeOutputFile.txt

So it's not a switch of osql but rather a DOS option to say to redirect the output to a file. > will create a new file or overwrite, >> appends.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Go to Top of Page
   

- Advertisement -