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.
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).
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.