Import multiple Excel files into SQL Server 2008 R

2019-06-25 23:59发布

I have to insert data into two tables from two different excel sheets using SSIS packges.

So, please some one tell me How to import multiple Excel files into SQL Server 2008 R2 using SSIS Packages?

3条回答
时光不老,我们不散
2楼-- · 2019-06-26 00:12

Use Foreach Loop Container --> Foreach File Enumerator. Then put your Data Flow in Foreach Loop Container. Table structure and sheet name have to be equal in every Excel file.

Here is nice tutorial: http://bi-polar23.blogspot.com/2007/08/loading-multiple-excel-files-with-ssis.html

查看更多
Summer. ? 凉城
3楼-- · 2019-06-26 00:28

You can create and use variables to hold Excel file path, then implement the package within a for-each-loop container to loop trough each excel files in the folder. Make sure that the files are having similar data format and same extension. Create an integration service project in Visual Studio and follow the steps below:

  1. Right Click on canvas and add Variable say "FilePath" and set type as String

  2. Drag a for-each loop to canvas

enter image description here

  1. Right click on for-each-loop and select "Edit" and add path and file extension and then select the variable from "Variable Mapping" tab as shown:

enter image description here

enter image description here

  1. Add a Data-flow task in to the loop and double click to open it.

enter image description here

  1. Add an Excel source and OLEDB destination (if destination is SQL Server). By right clicking on these controls and choosing "Edit", you can select appropriate folder for Excel and its Data Sheet as well as specify SQL server database credentials in the destination. Connect source and destination using blue arrow. Check and modify mappings between columns, if needed.

enter image description here

enter image description here

enter image description here

  1. Create an expression to read each file to the variable. This can be done by selecting created "ExcelConnectionManager" and select its "Expression" property and expand to set variables to "ExcelFilePath"

enter image description here

enter image description here

  1. And that is it. You are ready to execute the package by coming to Control flow tab and select "Start". enter image description here

Ref: https://www.encorebusiness.com/blog/import-data-from-multiple-excel-files-sql-ssis/

查看更多
该账号已被封号
4楼-- · 2019-06-26 00:34

since you have only 2 excel files and only two tables I don't see why use a foreach loop. Just follow this link and do it directly

If you need to insert from both excel files to both databases you can use a multicast component to create a copy of a dataset

查看更多
登录 后发表回答