Import Multiple Excel files to SQL Server

16,088

A solution I used is to combine multiple Excel files into one with multiple sheets. This can be done by running a VBA script (for example How to merge Excel files with VBA - thanks to Svetlana Cheusheva) then use the SSMS import wizard to load multiple sheets into multiple tables. In my case, I have 160 files, but they are not very big — 100 to 10000 rows — and it worked perfectly for me.

Share:
16,088

Related videos on Youtube

C.J.
Author by

C.J.

Updated on May 26, 2022

Comments

  • C.J.
    C.J. almost 2 years

    I have about 40+ excel files that I would like to import to SQL Server 2012. The import wizard is a great tool but it only allows me to import one file at a time.

    I want to avoid using SSIS because the import should be relatively easy - basically it is just a direct copy-paste with the first row in the Excel files being the column names, and the Excel Files name = Table Name.

    Is there any easy way to achieve this?

    Edited: Since the columns will change quite frequently, I would like to avoid creating the tables manually. The wizard is great because it will create the table for me automatically.

  • C.J.
    C.J. over 9 years
    I'm getting an error message: Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
  • HaveNoDisplayName
    HaveNoDisplayName over 9 years
    To create a linked server that accesses an Excel spreadsheet, you have to execute sp_addlinkedserver. follow technet.microsoft.com/en-us/library/ms175866(v=sql.105).aspx
  • C.J.
    C.J. over 9 years
    Msg 15028, Level 16, State 1, Procedure sp_addlinkedserver, Line 82 The server 'EXCEL' already exists. Msg 7302, Level 16, State 1, Line 2 Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
  • C.J.
    C.J. over 9 years
    When I executed sp_addlinkedserver, it was successful. But then I'm still getting the Cannot create an instance of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".. When I tried to re-exec again, it says the link already exist
  • Johan
    Johan about 5 years
    Welcome to Stack Overflow! While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.