0

I have a bunch of excel files (with tables) in a folder that I want to import into SQL Server. Is there a loop or some code that I can write in SQL that will go to file path, open the file and import the data into the table? (I have data for each state so opening 50 tables will be tedious and I am looking to avoid doing so.)

6
  • 1
    Sql Server Integration Services can do this: Loop through Excel Files and Tables by Using a Foreach Loop Container learn.microsoft.com/en-us/sql/integration-services/control-flow/… Commented Jan 3, 2020 at 17:50
  • @DavidBrowne-Microsoft Does the ADO.NET connection manager mentioned in the article need to be installed or is it included in SQL Server? Commented Jan 3, 2020 at 17:59
  • SSIS is an optional component of most editions of SQL Server. You can get the designer for SSIS with SQL Server Data Tools: learn.microsoft.com/en-us/sql/ssdt/…, which includes everything you need to build and test SSIS packages. Commented Jan 3, 2020 at 18:01
  • Is there a way to write the loop with out downloading any software? I am on a company computer and cannot download software. Commented Jan 3, 2020 at 18:03
  • 1
    Power Query for Excel can do this too. support.office.com/en-us/article/… You would load all 50 workbooks into a single workbook using Power Query in Excel, then load that one to SQL Server. Commented Jan 3, 2020 at 18:05

1 Answer 1

2

You can use Power Query for Excel to combine the workbooks into a single workbook, and then load that into SQL Server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.