How to copy query results with column headers?

This post was written by namwar on August 27, 2008
Posted Under: How-To, Information, SQL Server 2005, Tips
Results to Grid Option Screen

Results to Grid Option Screen

It is a very common practice that sometime you need to copy the query results from SQL Server Management Studio (SSMS) results tab to excel or any other application. The problem normally we face is that it does copy column headers and you have to write the column headers by your self. Here is the quick tip to enable column headers copying.

  1. In SSMS, open Tools menu and click Options
  2. Expand Query Results node and click Results to Grid
  3. Check Include column headers when copying or saving the results. Your screen will look similar to following:
  1. Click Save to save your settings.

Now, whenever you will copy the query results, column headers will be copied too.

Enjoy!

Reader Comments

Great tip, thanks for the information.

#1 
Written By Brody on January 6th, 2009 @ 5:12 pm

Can’t we get these column headers thru “open table” option?

#2 
Written By srinivas on August 11th, 2009 @ 7:35 pm

This works great with Office 2003 or excel 2003 but it does not work in excel 2007. Is there a trick to make it copy the headers to excel 2007?

#3 
Written By James Reeve on September 2nd, 2009 @ 3:48 pm

Add a Comment

required, use real name
required, will not be published
optional, your blog address