Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudieF...ew.msnw?&pps=k
Neil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison
Showing posts with label txt. Show all posts
Showing posts with label txt. Show all posts
Friday, March 9, 2012
osql syntax
Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudie...new.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudie...new.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison
osql syntax
Hi
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudieFamily/_whatsnew.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison
I am running osql utility like this...
C:\Temp>osql -U sa -P 5a -S %ServerName% -d pubs -Q "select title, notes
from titles" -o .\out.txt -s"," -w300 -h-1
And it produces the following in "out.txt":
== start of output ==
The Busy Executive's Database Guide
,An overview of available database systems with emphasis on common business
applications. Illustrated.
...
...
...
Sushi, Anyone?
,Detailed instructions on how to make authentic Japanese sushi in your spare
time.
(18 rows affected)
== end of output ==
Can anybody tell me
(a) how to remove the "(18 rows affected)" comment
(b) how to remove the %FieldValue% right padding. Ideally I'd like the
output to be
== start of output ==
%FieldValue%,%FieldValue%
%FieldValue%,%FieldValue%
== end of output ==
Thanks for any tips.
PS My actual queries will be bigger than bcp allows. I'd prefer not to have
to write the query as:
select '"' + title + '", "' + notes + '"' from titles
Cheers,
Neil Evans-Mudie
-. . .. .-.. / .--. ... -- -. .. -.-. .--. / . ...- .- -.
... -...- -- ..- -.. .. .
e: My@.myorg.com address is a spam sink
If you wish to email me, try neilevans underscore mudie at hotmail dot com
w: http://groups.msn.com/TheEvansMudieFamily/_whatsnew.msnw?&pps=kNeil
to avoid the rowcount, you can use -Q "set nocount on select title, notes
from titles". As far as I understand, you can't avoid the fixed width nature
of the output, apart from the concatenation solution you propose.
HTH,
Paul Ibison
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)
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)
Saturday, February 25, 2012
osql and line spacing
I am importing a query to a .txt file and for some reason my file is being
written double spaced! Is there a parameter I am overlooking that will
control this' I do not know how long my lines will be so I am setting them
to be arbitrarily long so that I know that the data will not force a carrage
return.
The statement I am using to excecute my query looks like this:
"osql -SServer -Uusername -Ppassword -h-1 -o C:\Test\test.txt -s","
-w"2000" -Q"Select ' + @.flds + ' from Mytable"
I build my query in the @.flds variable based on values in another table. I
know that that part works. I just can not figure out why my output ends up
double spaced.
Thanks in advance.swag: is word wrap on in your text viewer?
Rick wrote:
> I am importing a query to a .txt file and for some reason my file is being
> written double spaced! Is there a parameter I am overlooking that will
> control this' I do not know how long my lines will be so I am setting the
m
> to be arbitrarily long so that I know that the data will not force a carra
ge
> return.
> The statement I am using to excecute my query looks like this:
> "osql -SServer -Uusername -Ppassword -h-1 -o C:\Test\test.txt -s","
> -w"2000" -Q"Select ' + @.flds + ' from Mytable"
> I build my query in the @.flds variable based on values in another table.
I
> know that that part works. I just can not figure out why my output ends u
p
> double spaced.
> Thanks in advance.
>|||No, But I was using note pad. You made me curious so I tried word pad, all
was better.
THANKS!
"Trey Walpole" wrote:
> swag: is word wrap on in your text viewer?
> Rick wrote:
>
written double spaced! Is there a parameter I am overlooking that will
control this' I do not know how long my lines will be so I am setting them
to be arbitrarily long so that I know that the data will not force a carrage
return.
The statement I am using to excecute my query looks like this:
"osql -SServer -Uusername -Ppassword -h-1 -o C:\Test\test.txt -s","
-w"2000" -Q"Select ' + @.flds + ' from Mytable"
I build my query in the @.flds variable based on values in another table. I
know that that part works. I just can not figure out why my output ends up
double spaced.
Thanks in advance.swag: is word wrap on in your text viewer?
Rick wrote:
> I am importing a query to a .txt file and for some reason my file is being
> written double spaced! Is there a parameter I am overlooking that will
> control this' I do not know how long my lines will be so I am setting the
m
> to be arbitrarily long so that I know that the data will not force a carra
ge
> return.
> The statement I am using to excecute my query looks like this:
> "osql -SServer -Uusername -Ppassword -h-1 -o C:\Test\test.txt -s","
> -w"2000" -Q"Select ' + @.flds + ' from Mytable"
> I build my query in the @.flds variable based on values in another table.
I
> know that that part works. I just can not figure out why my output ends u
p
> double spaced.
> Thanks in advance.
>|||No, But I was using note pad. You made me curious so I tried word pad, all
was better.
THANKS!
"Trey Walpole" wrote:
> swag: is word wrap on in your text viewer?
> Rick wrote:
>
Subscribe to:
Posts (Atom)