?
Solved

Copy resultset to excel with headers included

Posted on 2007-07-19
5
Medium Priority
?
458 Views
Last Modified: 2012-05-05
Hi,

On Enterprise Manager, I used to highlight the columns on a result grid, then copy and paste it to excel (and the headers will be included).  We have upgraded to SQL 2005, and I cannot do it anymore  in SQL Server Management Studio.

Is there a way to copy an paste the result set of queries of views to excel, an include the headers with it?

Thanks.
0
Comment
Question by:crickpaolo
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:QPR
ID: 19526350
Not sure but you can run the query from within Excel which will give the headers.
Data - import data - new database query
Select a dsn and then type/paste your query there.
ok - return data to excel
0
 
LVL 9

Accepted Solution

by:
gpompe earned 2000 total points
ID: 19526576
Go to Tools->Options ->Query Results ->SQL server -> Result to Grid and select the option "Include column header when copying or saving"
0
 

Author Comment

by:crickpaolo
ID: 19531442
Thanks qgompe. I tried it but it does not work work for some reason. Is there a special way of cutting and pasting to excel?

Here's what I did:
1. Selected the option to "Include column header when copying and pasting"
2. Restarted SQL Management Studio
3. Clicked on the upper left corner of my result grid, to select the entire result grid
4. Right Clicked, the selected copy
5. Pasted on Excel

But it still only pastes the contents without the header. help?

 
0
 
LVL 9

Expert Comment

by:gpompe
ID: 19558379
Try selecting the same option but for "Result to Text" too
0
 

Author Comment

by:crickpaolo
ID: 19558501
Thanks qgompe.  The inlude headers option was already selected on the Result to text option.  It looks like I cannot include the headers whenever I export the result set from an Open Table or Open View.  It did work however when I exported the resultset from a Query.

I guess Microsoft just reversed this functionality in SQL Server 2005. In Enterprise Manager, you can export the headers when opening a table/view, but not when exporting recordsets from within  Query Analyzer.  Right now, it's the other way around...

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question