Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you transfer or export SQL Server 2005 data to Excel

Tags:

sql

sql-server

I have a simple SQL 'Select' query, and I'd like to dump the results into an Excel file. I'm only able to save as .csv and converting to .xls creates some super ugly output. In any case, as far as I can tell (using Google) this doesn't seem to be so straight forward. Any help would be greatly appreciated.

like image 465
YourMomzThaBomb Avatar asked Sep 17 '08 21:09

YourMomzThaBomb


People also ask

How do I export a SQL 2005 database?

To export the data, you can: Right mouse click on your database >> tasks >> export data. or copy/paste from/to table data view.


2 Answers

SSIS is a no-brainer for doing stuff like this and is very straight forward (and this is just the kind of thing it is for).

  1. Right-click the database in SQL Management Studio
  2. Go to Tasks and then Export data, you'll then see an easy to use wizard.
  3. Your database will be the source, you can enter your SQL query
  4. Choose Excel as the target
  5. Run it at end of wizard

If you wanted, you could save the SSIS package as well (there's an option at the end of the wizard) so that you can do it on a schedule or something (and even open and modify to add more functionality if needed).

like image 77
Ryan Farley Avatar answered Oct 05 '22 15:10

Ryan Farley


Use "External data" from Excel. It can use ODBC connection to fetch data from external source: Data/Get External Data/New Database Query

That way, even if the data in the database changes, you can easily refresh.

like image 38
Sunny Milenov Avatar answered Oct 05 '22 13:10

Sunny Milenov