SQL SERVER – Export Data From SSMS Query to Excel

Today’s blog post is actually a follow up of my earlier blog post SQL SERVER – Copy Data From SSMS Query Result to Excel. In the earlier blog post, we had discussed how to copy data from the resultset. In this blog post, we will discuss how we can directly export data from SSMS Query to Excel.

In SQL Server Management Studio (SSMS), open Query Window.

Next, select the option of sending Results to File. You can either do this by following ways.

  1. Select short cut CTRL + SHIFT + F
  2. Go to Tool Bar >> Query >> Results To >> Results to File

SQL SERVER - Export Data From SSMS Query to Excel queryexcel1

Once you run the query it will bring up the following pop up where we can save the result in the format of .rpt. You can save the file with any name. in the example, I have saved it with the name results.rpt.

SQL SERVER - Export Data From SSMS Query to Excel queryexcel2

Once you save the file with you can now open excel first.

Go to Menu >> Files >> Open and locate this file.

The file will bring up the following menu, where you can just review the data and click on the next.

SQL SERVER - Export Data From SSMS Query to Excel queryexcel3

SQL SERVER - Export Data From SSMS Query to Excel queryexcel4

SQL SERVER - Export Data From SSMS Query to Excel queryexcel5

You will see that excel will have all the data in the separate columns. You can save this file with your preferred format or keep it as xls file.

SQL SERVER - Export Data From SSMS Query to Excel queryexcel6

That’s it. We are done!

Reference: Pinal Dave (https://blog.sqlauthority.com)

Excel, SQL Server, SQL Server Management Studio, SSMS
Previous Post
SQL SERVER – Copy Data From SSMS Query Result to Excel
Next Post
SQL SERVER – Identify Datatype Using SQL_VARIANT_PROPERTY Function

Related Posts

Leave a Reply