We help IT Professionals succeed at work.

Copy resultset to excel with headers included

Medium Priority
Last Modified: 2012-05-05

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?

Watch Question


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
Go to Tools->Options ->Query Results ->SQL server -> Result to Grid and select the option "Include column header when copying or saving"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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?


Try selecting the same option but for "Result to Text" too


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...

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.