SQL Tips by Namwar Rizvi

August 27, 2008

How to copy query results With column headers?

Filed under: SQL Server 2005,tips — namwar @ 9:56 PM
Tags: , ,

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:
  4. Results To Grid Option Screen

  5. Click Save to save your settings.

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



Create a free website or blog at WordPress.com.