Sql-server – How to import an excel spreadsheet into SQL Server

excelimportsql-server

I need to import an excel spreadsheet into SQL Server 2005. What steps would I need to take to accomplish that?

Best Solution

The "Data Transformation Services" wizards are your friend.

The instructions here assume SQL Server 2000

  • Open SQL Server Enterprise Manager
  • Right-click on the appropriate server
  • Select Import Data
  • Run through the wizard.
    • Click Next on the first screen
    • Choose "Microsoft Excel " as your datasource
    • Enter the path to the XLS file and click next.
    • Enter the connection details for your database and click next.

Depending on what you want to do with the data, you have a few options new. For one-off jobs I generally find it easiest to import all the excel data, then edit it in SQL Server, but if you're going to repeat this action on multiple files, you might want to craft a really sexy import script.

If you are going to run it again, you can save the DTS package using the wizard, then edit it in the "Data Transformation Services" section of Enterprise Manager. It's a good way to learn how DTS works.