SQLServer 2000 - export query results to Excel

How to export query results from Query Analyzer Results pane to include the column headings.  Currently I am adding the column headings manually.

I know how to export without the headings:
http://www.experts-exchange.com/Database/Miscellaneous/Q_21849293.html?sfQueryTermInfo=1+pane+result+sqlserver#a16673638

thx alot experts
GeorgeJacobsonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dbaSQLConnect With a Mentor Commented:
oh i'm sorry.  i didn't read closely enough -- you are talking about to excel directy from query analyzer result pane.

still, this can be done

go to tools/options
generat tab:  change result file extension to .csv
results tab: change results output format to 'comma delimited (csv)'
results tab:  make sure 'print column headers' is checked

then, just exec your query just like before.  when you want a csv file as output, change the results from Grid/Text to File and run the query again.
0
 
dbaSQLCommented:
Easily done via DTS to csv Transform Data Task
-Set up sql server connection, set up text file (destination), and do a transform data task between each
Within that task you can write any query you like, though ideally, you're using a procedure.
Put it in, parse it, define your transformations simply as a copy of all columns.
Double click the text file (destination), it opens a dialog box 'connection properties' --
bottom right, choose 'properties', go in there and opt file type, row and column delimiter and text qualifier.

There is also a 'First row has column names' option
Check it
And you're good to go
0
 
GeorgeJacobsonAuthor Commented:
If I use DTS that means I would have to run query results into a table first (or view)?  That is, the source for DTS needs to be a table?
Thx alot dbaSQL.  (too bad SQLServer does not have a File Export feature like MSAcess!)
0
 
GeorgeJacobsonAuthor Commented:
Thank you very much dbaSQL (my last post was before I saw this post/solution)
0
 
dbaSQLCommented:
Very good, I hope everything works out.
0
All Courses

From novice to tech pro — start learning today.