SQL Server Export to Excel


sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO 

https://www.microsoft.com/en-us/download/details.aspx?id=23734

USE [master]
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
GO
EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
GO

Wizard

From within SQL Server you can use the wizard to export a tables or tables (using a view for example) to an Excel spreadsheet.

Choose a data source. The data source is SQL server and the drop down choice is .NET Framework Data Provider for SQLServer. Set the Integrated Security to true if you are using integrated security. Set the Data Source to the name of the computer, backslash the name of the SQL Server. If you are doing this locally you can get this information from SSMS by running the query: PRINT @@servername. Set the Initial Catalog to the name of your database.

After you click Next, you will be asked to choose a destination. In the drop down, choose Microsoft Excel. Click the Browse button to find the Excel file you want to export to. For me, I chose an xls file, which is a older format. Click Next.

You have two choices. You can export a whole table or view’s worth of data, or you can choose to specify a query. For simplicity in this first example, choose the table option and click Next

In this part of the wizard you are asked to specify one or more tables or views. Select a table in your database.

The next screen is Review Data Type Mapping. If you are satisfied, click Next.

You can run immediately and you can also choose to save an SSIS package. For now just click Next.