• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Wanted: no column headers in output file

I'm using MSSQL 2000 osql to run scripts against databases for monitoring purpose.
The output of the script is saved into an output file.

I would llike to get rid of the column headers in the output file.
So instead of

Column A  Column B
-----------   -----------
a                1

I would like to get
a       1

What parameter of option can i use either with osql or within the t-sql script?
Ronny Stijns
Ronny Stijns
  • 4
  • 2
1 Solution
You could do this:

@echo off


set oldFile=output.txt
set newFile=newFile.txt

del "%newFile%" 2>NUL

for /f "tokens=* skip=2" %%a in ('type "%oldFile%"') do (echo %%a)>>"%newFile%"

echo Output in "%newFile%"

Good Luck,
Looks like you can use the -h parameter to do this task:

osql -h-1 -S . -d northwind -E -Q "select top 5 * from orders"
Ronny StijnsAuthor Commented:
I tried the -h options, but it still gave me headers in the outputfile.
I'll try the answer Steve gave.

To be continued.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

The -h work for me as did my manual batch file processing. Maked sure not specify the parameter exactly:


No spaces in between characters for this parameter.
Ronny StijnsAuthor Commented:
Thanks Steve for the solution.
It must be -h-1 instead of -h.

Yes, that will do the trick.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now