SQL SERVER – Copy Column Headers from Resultset – SQL in Sixty Seconds #027 – Video

SQL Server Management Studio returns results in Grid View, Text View and to the file. When we copy results from Grid View to Excel there is a common complaint that the column  header displayed in resultset is not copied to the Excel. I often spend time in performance tuning databases and I run many DMV’s in SSMS to get a quick view of the server. In my case it is almost certain that I need all the time column headers when I copy my data to excel or any other place.

SQL Server Management Studio have two different ways to do this.

Method 1: Ad-hoc

When result is rendered you can right click on the resultset and click on Copy Header. This will copy the headers along with the resultset. Additionally, you can use the shortcut key CTRL+SHIFT+C for coping column headers along with the resultset.

Method 2: Option Setting at SSMS level

This is SSMS level settings and I kept this option always selected as I often need the column headers when I select the resultset.

Go Tools >> Options >> Query Results >> SQL Server >> Results to Grid >> Check the Box “Include column header when copying or saving the results.”

Both of the methods are discussed in following SQL in Sixty Seconds Video.

Here is the code used in the video.

Related Tips in SQL in Sixty Seconds:

If we like your idea we promise to share with you educational material.

Reference: Pinal Dave (http://blog.sqlauthority.com)

7 thoughts on “SQL SERVER – Copy Column Headers from Resultset – SQL in Sixty Seconds #027 – Video

  1. Pingback: SQL SERVER – Wrap SQL Code in SSMS – SQL in Sixty Seconds #038 – Video « SQL Server Journey with SQL Authority

  2. Pingback: SQL SERVER – Weekly Series – Memory Lane – #048 | Journey to SQL Authority with Pinal Dave

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s