Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 easy questions...

Status
Not open for further replies.

kennethc

Programmer
Jan 10, 2001
4
US
1) Is there anything in MSQL similar to a 'spool' cmd in Oracle? I want to save query results to a file, thats all.
2) How can I turn the headings off in query results. I know about the -h-1 option, but how do I do this in a query?
Thanks.
 
Kenneth,

If I understand you correctly, you want the query results saved into a file (i.e., txt, csv) and not show the headers from MS SQL Server 7.0.

If true, you can do the following:

1. From MS Query Analyzer, insert the T-SQL.
2. Before executing the query (Ctrl + E), setup the results
to show Results In Grid format (Ctrl + D).
3. Highlight each column (field) header you want to save
(Shift + left-mouse click).
4. Right-mouse click a highlighted column, select Save
Selection... .
5. From the Save Grid Results screen, select the directory
, file name, type (extension, default *.csv), format
(Unicode, ANSI, or OEM; default ANSI), and column
delimiter (comma, tab delimited).
6. To view the results, open the file (from step 5) in MS
Excel, or a text editor (i.e., MS Wordpad).

NOTE: by returning the Results In Grid format and saving them as a *.csv file, you're results will neither contain header columns nor result headers (i.e., row counts).

Hope this helps.

Paul
 
Thank Paul,
That gives me another option in the future. I was able to figure another way of doing it. I just created a .bat file that executed the stored proc with the parameters to remove the headers (-h-1), comments (nocount), and pipe output (-O). This is acutually better, since ultimately end users don't have to use QA.

Thanks again,
Ken
 
If u r doing it in QA, u cqn turn headings off by Tools-> Options->Results Tab-> checkbox for Print column headings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top