SSMS Query Results: “Include column headers when copying or saving the results"

In my work with external customers, I collaborate with some excellent DBAs & Architects.  But I've noticed many of them are not aware that you can capture column headers from query results to grid in SSMS.

When a very bright engineer I work with—not a SQL SME yet one of the smartest guys I know—told me he didn't know about it either, I decided to document the simple protocol.  I'm not the first person to post this topic, but I wouldn't need to do so if everyone already knew about it.

There are two ways to get the column headers from SSMS into, say, Excel.

The Hard Way 

You can simply type out the column names by hand.

The Right Way

Make it the SSMS default:

  • Open SSMS
  • Click Tools > Options
  • In the Options dialog, expand Query Results > SQL Server > Results to Grid, then check “Include column headers when copying or saving the results”
  • Click OK
  • Close & restart SSMS

image 

As my friend the cellist says, "Viola! "

The steps are the same for SQL Server 2005 & 2008.

Additional Resources

Explore these topics for additional information on SSMS options & increase your SSMS productivity.

Administrivia

Jimmy May , MCDBA, MCSE, MCITP: DBA + DB Dev | Senior Performance Consultant: SQL Server
A.C.E.: Assessment Consulting & Engineering Services
https://blogs.msdn.com/jimmymay
Oh, the weather outside is frightful, but SQL Server is delightful! —Brian Moran

This post was written with the PracticeThis.com plugin for Windows Live Writer