Export SQL table to Excel using Sql to Excel Utility
Perhaps the simplest way to export SQL table to Excel is using Sql to Excel utility that actually creates a CSV file that can be opened with Excel. It doesn’t require installation and everything you need to do is to connect to you database, select a database and tables you want to export:
After you press “Generate CSV” it will create a separate CSV file for each table in the selected folder.
You can find more information on the official page.
Export SQL table to Excel using SSMS
There are two options of exporting the data from SQL Server Management Studio to a file.
1. Quick and easy
This option will work fast for you if you have both Excel and SSMS installed on the same machine. If you don’t have it or cannot access Excel for whatever reason, but you still need the data exported, go to the next option.
The first one is to write a query and run it. After writing your simple query that outputs the contents of a table or a more complicated query and want to save the result set into a .csv or .xls file, this is what you have to do.
You click on the top left rectangle which will select all of the data resulted from your query.
You then right click on the result set and select either Copy or Copy with Headers, which will also select the column names, so you know what data represents in your column.
Then you simply go to an Excel file and right click and then Paste the results onto the spreadsheet.
2. Safe and secure
This option works great when you don’t have access to both SQL Server Management Studio and Excel on the same machine.
In order to export data from one or multiple tables in either a custom way or just export all data, this is the option to use.
Going into SSMS and right clicking on the database and then going to Tasks you will see a option called Export Data, which you will have to click.
After clicking Export Data, a new window will appear where you will have to select the database from where you want the data exported.
After selecting the Data Source you’ll press Next and get to a window where you will have to select the Data Destination.
You will have a drop-down menu, like the one you can see below where you will have to select Excel as destination type.
The next step would be to browse to the location of where the file will be created and input its name. Also, you should select the version of Excel you want the file to be created for.
Press Next and get to the next Wizard window where you have the option of either running a custom query to output custom data from your tables, or just select all data from more tables.
Choose whatever version works best for you, but for now let’s just say you want to export all data from a specific table and thus you’ll choose the first option.
The next window you will see will have you select the table or tables you want to select data from. Select the table you want to expor data from and either press Next or Edit Mappings.
Press Next to get to the next step of the wizard. You will get to a window where you have the option of running the query “Right Now” and also create an SSIS package.
After you’ve selected the options you’d like, press Next. You will get to the last window of this wizard where you will have to press Finish.
This will create the export file to the file path you specified with the file name you have selected.
If we go to review the file, you can see that the data is in that specific format.