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

Posted by pinaldave on SQL Authority See other posts from SQL Authority or by pinaldave
Published on Wed, 26 Sep 2012 01:30:37 +0000 Indexed on 2012/09/26 3:42 UTC
Read the original article Hit count: 476

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)


Filed under: Database, Pinal Dave, PostADay, SQL, SQL Authority, SQL in Sixty Seconds, SQL Query, SQL Scripts, SQL Server, SQL Server Management Studio, SQL Tips and Tricks, T SQL, Technology, Video

© SQL Authority or respective owner

Related posts about database

Related posts about Pinal Dave