Wednesday, March 7, 2012

osql help

If i am running multiple osql, how can I append to a common output file such
as
osql -S ServerA -i q1.txt -o out.txt
osql -S ServerB -i q1.txt -o out.txt
Havent tried it but wanted to know of the second osql command would
overwrite the first out.txt file and if it does, how can I append the
results ?
ThanksOsql will overwrite the file. Your option is to output to 2 seperate files
and then concatenate them.
e.g.
osql ... -ofile1.txt
osql ... -ofile2.txt
type file1.txt file2.txt > final.txt
-oj
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:OeukWsTFFHA.2676@.TK2MSFTNGP12.phx.gbl...
> If i am running multiple osql, how can I append to a common output file
> such
> as
> osql -S ServerA -i q1.txt -o out.txt
> osql -S ServerB -i q1.txt -o out.txt
> Havent tried it but wanted to know of the second osql command would
> overwrite the first out.txt file and if it does, how can I append the
> results ?
> Thanks
>|||On Thu, 17 Feb 2005 13:53:15 -0800, Hassan wrote:

>If i am running multiple osql, how can I append to a common output file suc
h
>as
>osql -S ServerA -i q1.txt -o out.txt
>osql -S ServerB -i q1.txt -o out.txt
>Havent tried it but wanted to know of the second osql command would
>overwrite the first out.txt file and if it does, how can I append the
>results ?
Hi Hassan,
You can remove the -o option (so that output will be sent to the screen),
then use Windows' output redirection operators (> and >> ) to redirect that
output to file
osql -S ServerA -i q1.txt > out.txt
osql -S ServerB -i q1.txt >> out.txt
The first line will create or overwrite the file; the second line will
append to it.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment