Skip to content
Guide · SSMS

How to Export Query Results to Excel/CSV in SSMS

Since SSMS 22.4.1 you can save a results grid straight to an Excel workbook, as well as CSV, text, JSON, XML and Markdown, from the Save Results As option; SSMS 22.10.2 added an include-headers checkbox to that dialog. This guide covers that route and the others Microsoft documents: copying with headers, sending results to a file, the Export Data wizard for whole tables, and bcp for large or scheduled exports.

Steps and facts checked 8 October 2026 against the vendor's official documentation. Versions covered: SSMS 22.10.2 (Excel, JSON, XML and Markdown export from SSMS 22.4.1). Next review due April 2027. Menus, shortcuts and prices change between releases; check the vendor's documentation for your version.
Short answer
  • In SSMS 22.4.1 and later, right-click the results grid, choose Save Results As, and pick Excel, CSV, TXT, JSON, XML or Markdown in Save as type.
  • SSMS 22.3.3 and earlier save only CSV and TXT; update SSMS to get direct Excel export, and to 22.10.2 for the include-headers checkbox and a fix for .xlsx files that misbehaved in Excel.
  • For a quick paste into Excel, select the grid and press Ctrl+Shift+C to copy results with column headers.
  • For large results, Results to File (Ctrl+Shift+F) writes straight to disk, and bcp with queryout exports from the command line.
How we know: Research-based: the menu paths, file formats, version numbers and shortcuts come from Microsoft Learn (Query results in SSMS, SSMS 22 release notes, SSMS tips and tricks, SSMS keyboard shortcuts, the Import and Export Wizard pages and the bcp utility reference), checked on 8 October 2026. We have not run these exports for this guide and it has no screenshots; Microsoft does not document how each format handles every data type, so check a sample file before relying on it.

SSMS export to Excel or CSV with Save Results As

This is the route most people want. It works on whatever the query returned in Results to Grid, the default output.

  1. Run the query with results in the grid (Ctrl+D switches the window to grid output).
  2. Right-click anywhere in the results grid and select Save Results As....
  3. In the Save Grid Results dialog, enter a file name and choose the format in Save as type.
  4. In SSMS 22.10.2 and later, tick the checkbox to include column headers if you want them in the file.
  5. Select Save. SSMS remembers the last file type you used.

If a query returns several result sets, each appears in its own grid; right-click the one you want. The default folder is set in Tools > Options > Query Results > SQL Server > General > Query results directory.

Save Results As formats by SSMS version (Microsoft Learn)
SSMS versionFormats in Save as typeNotes
22.3.3 and earlierCSV, TXTOpen the CSV in Excel, or copy and paste
22.4.1 (March 2026) and laterCSV, TXT, Excel, JSON, XML, MarkdownDirect .xlsx export added
22.10.2 (September 2026)As aboveInclude-headers checkbox in Save Grid Results; fix for .xlsx files that caused selection errors in Excel

Copy and paste into Excel with headers

For small results, copying is quicker than saving a file. Microsoft lists Ctrl+Shift+C as "Copy the result grid and headers to the clipboard". The grid lets you copy selected rows, columns or the full result set, with or without headers, from the right-click menu. Paste into Excel with Ctrl+V.

Check long numbers and leading zeros after pasting: Excel applies its own type detection to pasted text, which SSMS does not control.

Results to File and Results to Text

Results to File writes the output straight to disk instead of rendering it, which Microsoft suggests for large result sets. Press Ctrl+Shift+F (or use the SQL Editor toolbar), run the query, then choose a folder, file name and Save as type in the Save Results dialog. The default is a report file with the .rpt extension; the arrow on the Save button offers Save with Encoding.

Results to Text (Ctrl+T) prints delimited text in the Results window. The column separator and maximum column width are set in Tools > Options > Query Results > SQL Server > Results to Text. The destination you choose applies to the current query window and takes effect on the next run.

Export whole tables with the Export Data wizard

To export one or more tables (or a query) to an Excel workbook or a flat file without writing results to the grid, use the SQL Server Import and Export Wizard: right-click the database, point to Tasks and select Export Data. In SSMS 22 the wizard comes with the Integration Services component of the Business Intelligence workload.

  • Choose your SQL Server database as the source and an Excel workbook or a flat file as the destination on the Choose a Destination page.
  • For Excel, enter the Excel file path, choose the Excel version, and set First row has column names.
  • You may need to install extra files (the Excel connectivity components) before Excel appears. Microsoft notes the Excel providers are typically 32-bit and are not visible in the 64-bit wizard, so if Excel is missing, that is the usual cause.
  • The wizard cannot open a password-protected Excel file.

Large or scheduled exports with bcp

The bcp utility exports from the command line, which suits scheduled jobs and results too large for the grid. queryout copies the result of a query (only the first result set), -c uses character format, -t sets the field terminator (tab by default), -S names the server and -T uses Windows integrated security. bcp writes delimited text, not .xlsx; open the file in Excel afterwards.

Command line: export a query to a comma-separated file with bcp (documented options; replace the placeholders)
bcp "SELECT CustomerID, FullName, City FROM mydb.dbo.Customers" queryout C:\exports\customers.csv -c -t, -S <your-server> -T

Frequently asked questions

How do I export SSMS results to Excel?

In SSMS 22.4.1 or later, right-click the results grid, choose Save Results As... and pick the Excel file type. In older versions, save as CSV and open it in Excel, or copy with Ctrl+Shift+C and paste.

How do I include column headers when saving results?

SSMS 22.10.2 added a checkbox to the Save Grid Results dialog to include column headers. When copying, use Ctrl+Shift+C, which copies the grid and headers.

Why does my SSMS .xlsx export show errors in Excel?

SSMS 22.10.2 fixed an issue where .xlsx files exported from SSMS behaved erratically in Excel, including a multiple-selection error. Update SSMS through the Visual Studio Installer and export again.

What is an .rpt file in SSMS?

It is the default file type for Results to File: a plain report-style text file. Choose a different type in Save as type when the Save Results dialog opens.

How do I export a very large result set?

Avoid rendering it in the grid. Use Results to File (Ctrl+Shift+F), the Export Data wizard, or bcp with queryout from the command line.

Sources

Checked 8 October 2026.

How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.

Still choosing a SQL client?

Read the full reviews, or compare tools side by side.