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.
- Select short cut CTRL + SHIFT + F
- Go to Tool Bar >> Query >> Results To >> Results to File
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.
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.
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.
That’s it. We are done!
Reference: Pinal Dave (https://blog.sqlauthority.com)