ISQL Output File

I am using ISQL to run a query and create an output file. When it does this it prints column headings and underneath those, prints a dashed line. Is there anyway to eliminate the column headings and dashed line so that is it just the data that is contained in the output file?
rkanoAsked:
Who is Participating?
 
formulaConnect With a Mentor Commented:
Rkano,

I'll be out of pocket for awhile, so I'm submitting as an answer.  As usual, if you don't think it solves your issues, you can reject it.  Thanks!!

Answer:
Use isql command line utility /h-1 to remove headers from single query.  Also, use isql /s option to get rid of leading blank in output file.
0
 
JHausmannCommented:
Click on the query options button (or select set options... from the query menu). Then select the format tab. De-select print headers by clicking on the checkbox.
0
 
rkanoAuthor Commented:
Won't de-selecting 'print headers' clear that option for all queries? In other words, there are a couple of queries that I would like to have column headings, so could I set this option on that query only?
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
formulaCommented:
There is no "set print headers" command to do this for a specific query.  I suppose Microsoft forgot this one.

A solution however to your dilema is to create a stored procedure which calls the isql command line utility using  the "xp_cmdshell" stored procedure to output your file.  That way you can take advantage of the options available to the isql command line utility, including one to turn off headers.  Hope this helps!!
0
 
rkanoAuthor Commented:
Excellent! That worked, however, now I have one other problem related to this. Now that I generate an output file using ISQL, it forces a space in the first column of the output file. FOr example, a line from the output file looks like this:

 1222990001234D

instead of this

1222990001234D

Forcing a space in that first column is causing the import of this data into other systems not to work. Any ideas?
0
 
formulaCommented:
Keep in mind that I'm not sure the solution you chose based upon your message(formula or Jhausmann). Either way though, I haven't seen this behavior before, so I'm speculating on it's possible solution:
1) Must be a character field, so try ltrim(field) in your query.
2) If you used isql command line util, make sure you used the /h-1 option without a space between h and -.
0
 
rkanoAuthor Commented:
Sorry about that, I did clear up the column headings problem.

It is indeed strange, I am just doing a "select * from" a table and sending the results to an output file. It is forcing a blank character in the first position. If I am in a SQL Query window and do a "select * from" on that table, it displays correctly. Also, if I go to the results window and save it as a text file, it saves it in the correct format. It is only using ISQL where it forces that first blank character. Anyway, here is my ISQL statement:

cmd /c isql -S IMPREDSDDB01 -U xxxx -P xxxx -d Y2K -Q "OutPut_Wires_File"
-h-1 -w 150 > \\IMPREDSDDB01\OptQueue\Y2KDB\Output\Output_Wire.TXT
0
 
formulaCommented:
Add the /s option to your isql command and the blank will disappear.
0
All Courses

From novice to tech pro — start learning today.