?
Solved

How do I customize the header using OSQL

Posted on 2007-07-23
2
Medium Priority
?
646 Views
Last Modified: 2011-10-03
I have a DOS batch job that runs an OSQL command.

osql -dION_Data -E -ieaf8.sql -l -n -oeaf8.txt -s"      " -SMAPOW\ION -w500

If I use the -h-1 parameter, I see just the data:
23-Jul-2007 11:11:11.00<TAB>1.0<TAB>22.2222<TAB>&
23-Jul-2007 11:11:12.00<TAB>1.0<TAB>22.2222<TAB>&
23-Jul-2007 11:11:13.00<TAB>1.0<TAB>22.2222<TAB>&

If I omit the parameter, I see the column name and a line of hyphens:
DATETIME<TAB>TAP_POSITION<TAB>CURRENT_PHASE_A<TAB>&
------------<TAB>------------------<TAB>--------------------------<TAB>&
23-Jul-2007 11:11:11.00<TAB>1.0<TAB>22.2222<TAB>&
23-Jul-2007 11:11:12.00<TAB>1.0<TAB>22.2222<TAB>&
23-Jul-2007 11:11:13.00<TAB>1.0<TAB>22.2222<TAB>&

Is there a way to keep the column names and suppress the 2nd line (the hyphens)?
If not, I need to suppress the header (-h-1) and manually output the column names (tab delimited).  How can I do this from my SQL input file?
0
Comment
Question by:sainiak
2 Comments
 
LVL 3

Accepted Solution

by:
Askeeto earned 2000 total points
ID: 19554055
suppress the header and construct your query like this.

select 'col1', 'col2'
union all
select col1, col2
from yourtable

If you want to use an order by you need to include the column in the header line as well
0
 

Author Comment

by:sainiak
ID: 19558449
I had to add a few converts to the 2nd query, and then it worked.  I am no SQL expert, but I think this is because the datatypes must be the same in both queries.  Thanks!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question