Export SQL Data to Excel with Column Headers

How many times have you had to write up a quick query in SQL Management Studio for someone and then export it out to Excel? Exporting data from SQL is a fairly long process and involves several steps, but once you do it a few times, it’s not bad.

One thing I learned about saving SQL query results into Excel format or CSV format is that it’s best to use the SQL Import and Export Wizard rather than trying to right-click on the results and saving them.

export sql  to excel

You can always right-click and choose Save Results As, however, the CSV file that you get will not contain the column headers! This is a royal pain if you have 50 columns.

To export SQL data the correct way, right-click on the database (not the table) and choose Tasks, Export Data.

tasks export data

Next, you need to choose the Data Source. If you right-click on the database name, then everything should come up automatically.

choose data source sql

Now you need to choose the Destination. Go ahead and pick Microsoft Excel from the drop down list. After that, you will need to click Browse and choose the location for the output Excel file. Also, be sure to keep the “First row has column names” box checked.

sql data to excel

Next, you can either choose export an entire table/view to Excel or to write your own query. In my case, I will write a specific query that I want to export.

export data to excel

Type in your query and then click Parse to make sure that everything is correct.

export sql query

Finally, click Next and then click Finish. Your SQL data will be outputted into an Excel file and it will include all the column headers too! Enjoy!

More posts from the How-To Category

Installing New Themes For SMPlayer

Selecting Add-ons from the Tools menu

Remove Dead and Duplicate Bookmarks from Firefox

Automatically Edit MP3 Metadata From The Terminal With Beets

Enable Transparent Label Text Background On The Xfce Desktop

Popular Posts This Month

windows defender

Windows Defender vs. Security Essentials vs Safety Scanner

youtube ie11 freezing

How To Fix Flash Crashes in Internet Explorer 11

bitlocker error

Fix “This device can’t use a Trusted Platform Module” When Enabling BitLocker

Comments [3]

  1. Saravana says:

    You can just modify the options for the SQL ServerResults To Grid option, available in the Tools menu, to include column headers when you save/copy results

  2. rodoss says:

    Thanks!

  3. kathleen says:

    I don’t know why it took me so long to find this – I’ve been trying to figure this out for a while – THANK YOU! Didn’t have any luck with the grid option suggested by Saravana – I was already set to grid and that doesn’t export the headers (at least not when I do it)

Leave a Reply