September 17, 2004 at 6:12 pm
I want to run osql and use -o option to redirect the result, which is result set of a query. But what in the output is something like
------------------------------------------------ -----------
-----------
feeschedulesql
adm
NULL NULL
NULL NULL job not configured
NULL
This seems those in the executing messgae window and result of ill formated.
How can I format the output like a table, like in SQL Query Analyzer result window, and get rid of executing messages.
thanks
September 20, 2004 at 6:56 am
You need to create fixed sized variables for each column in the select query that can then be used to generate the result set.
E.g
declare @res1 varchar(20)
declare @res2 varchar(10)
select @res1 = left(col1,20),
@res2 = left(col2,10)
from table
You will then get fixed sizes so that the columns line up.
Also to increase width of text file use:
-w
For more parameters see:
http://www.sql-server-performance.com/rd_osql.asp
September 21, 2004 at 2:51 pm
You might also want to use BCP instead. BCP can now have a query specified instead of a table name for source and can then output in tab delimited format.
Also, you should only need the -w parameter: output should be padded appropriately with spaces.
September 21, 2004 at 6:11 pm
This worked. Thank you, both of you.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply