How to Export SQL Data to Excel with Column Headers

·
4 min read

Help Desk Geek is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

If you’ve ever right-clicked query results in SQL Server Management Studio and chosen Save Results As, you already know the problem: the CSV comes out with no column headers, which is useless when you’re handing a 40-column spreadsheet to someone. The SQL Server Import and Export Wizard fixes that, and Excel’s built-in Power Query is even faster for anything you need to refresh regularly.

Method #1: Export via the SQL Server Import and Export Wizard (SSMS 20.x)

This is the most reliable method for a clean one-time export with headers intact. Works in SSMS 20.2 and any earlier version.

  1. Open SSMS and connect to your SQL Server instance.
  2. In Object Explorer, right-click the database name — not a table, the database itself.
  3. Select Tasks > Export Data. The Import and Export Wizard opens.
SSMS 20.x Object Explorer with a database right-clicked, showing Tasks > Export Data menu option highlighted
  1. On the Choose a Data Source screen, the server name and database should auto-populate if you right-clicked the correct database. Confirm the authentication method and click Next.
Import and Export Wizard "Choose a Data Source" screen with SQL Server Native Client selected, server name and database pre-filled
  1. On the Choose a Destination screen, open the Destination dropdown and select Microsoft Excel.
  2. Click Browse and choose where to save the output file. Select .xlsx as the format — avoid the older .xls format, which has a 65,000-row limit.
  3. Make sure First row has column names is checked. Click Next.
Import and Export Wizard "Choose a Destination" screen with Microsoft Excel selected as destination, .xlsx file path entered, and "First row has column names" checkbox checked
  1. On the Specify Table Copy or Query screen, select Write a query to specify the data to transfer if you want a custom result set, or Copy data from one or more tables or views for a full table dump. Click Next.
  2. If you chose the query option, type your SQL query in the box and click Parse to validate it before continuing.
Import and Export Wizard "Provide a Source Query" screen with a SELECT statement typed in the query box and the Parse button highlighted
  1. Review the column mappings on the next screen. Headers should map automatically. Click Next, review the summary, and click Finish.

The wizard runs the export and reports success or any row-level errors. Open the output file – all column headers are in row 1.

Import and Export Wizard execution summary screen showing "Success" status with row count

Method #2: Use Excel Power Query (No SSMS Required)

Power Query connects Excel directly to SQL Server and pulls data with headers automatically. The real advantage: you can refresh the query any time without going back to SSMS. Requires Excel 2016 or Microsoft 365.

  1. Open Excel and click the Data tab.
  2. Click Get Data > From Database > From SQL Server Database.
Excel 365 Data tab with Get Data > From Database > From SQL Server Database menu path highlighted
  1. Enter your Server name. Optionally enter the Database name in the second field. Click OK.
  2. Choose your authentication method (Windows or Database credentials) and click Connect.
  3. In the Navigator pane, select the table or view you want, or click Transform Data to write a custom SQL query before loading.
Excel Power Query Navigator pane showing a SQL Server database with tables listed and a preview of selected table data including column headers
  1. Click Load to drop the data directly into a worksheet with headers in row 1, or Load To to choose a specific sheet or table format.

To refresh the data later, right-click anywhere in the result table and select Refresh, or go to Data > Refresh All.

Method #3: Copy with Headers from SSMS (Quick but Finicky)

This works for small, quick exports where you don’t want to run the wizard. The catch: Excel sometimes pastes everything into a single column instead of separate columns.

  1. Run your query in SSMS.
  2. Right-click anywhere in the results grid and select Copy with Headers.
  3. Switch to Excel, click a cell, and press Ctrl + V.

If the data lands in one column instead of spreading across multiple columns, here’s the fix:

  1. In Excel, click any empty cell and type a few words separated by a tab character (copy-paste from Notepad if needed).
  2. Select that cell, go to Data > Text to Columns, choose Delimited > Tab, and finish the wizard. This resets Excel’s remembered delimiter to Tab.
  3. Now paste your SQL results again — they should split into columns correctly.
Excel Data tab with Text to Columns wizard open, "Delimited" selected and Tab checkbox checked in step 2

Troubleshooting Common Export Issues

ProblemCauseFix
Headers missing in CSV from Save Results AsSSMS default behaviorUse the wizard or Copy with Headers instead
Copy with Headers pastes into one columnExcel’s delimiter memory set to commaReset to Tab via Text to Columns on dummy data
Wizard fails on Azure SQL with auth errorAzure AD auth not pre-configuredSet up the connection in SSMS before launching the wizard
Export crashes on large datasetsExcel’s ~1M row limitExport to CSV via BCP utility, then open in Excel
Date columns show wrong format in ExcelSQL date type vs. Excel date type mismatchCast the column in your query: CONVERT(varchar, datecol, 103)

Conclusion

The Import and Export Wizard is the most dependable option for a clean one-time export, it’s been the right answer since SSMS existed and nothing has changed there. If you’re pulling the same data more than once, Power Query is the smarter move: connect once, refresh whenever you need it, and never touch the wizard again. The “Copy with Headers” shortcut is fine for a dozen rows, but don’t rely on it for anything serious.