Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting from SQL Server to Excel with column headers?

I have a query that has approximately 20 columns and I would like to export this to an Excel file with the column headers.

I thought this would be easy to figure out but no luck! I searched the web and found one suggestion that did not end up working so I am stuck.

like image 538
Mark Kadlec Avatar asked Mar 12 '09 18:03

Mark Kadlec


People also ask

How do I copy a column name from SQL Server to Excel?

Select cells from the columns you want to copy (CTRL+Click), choose "Copy selected Headers" in Results grid context menu and column names will be copied to clipboard. This action creates a comma-separated list that can be pasted wherever you need.

How do I copy a header from SQL to Excel?

If you use Microsoft SQL Management you can right click and choose the option to "Copy with headers". Ctrl + Shift + C is the default command.


1 Answers

I typically do this by simply click the upper left corner in the results grid, copy, and then paste into Excel. There is one catch, you need to go into options->query results-> SQL Server->results to grid (or text if you want to save to file for import into excel) and turn on include column headers when copying or saving the results. I find this works great.

like image 177
Codezy Avatar answered Sep 16 '22 17:09

Codezy