Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
159 views
in Technique[技术] by (71.8m points)

SSIS package configurations

how to load multiple Excel files using SSIS. I have had Packages in the past where I was looping through multiple Text files in a folder and loading them into SQL server tables.

question from:https://stackoverflow.com/questions/65713879/ssis-package-configurations

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Create a variable named FileName, set the scope to ImportMultipleExcelFiles, Data type is String.

Add a Foreach Loop Container in the Control Flow Task.

Edit the Foreach Loop Container, in the Collection section change the Enumerator value to Foreach File Enumerator

You need to change the Enumerator configuration as shown below :

  • Folder: Provide a complete folder path location where all our Excel source files are stored.
  • Files: you need to read the Excel files from our source folder, so enter *.xls in the Files section, this will make sure our SSIS package will read all available .xls files from the source folder. Here * indicates that the Excel file name can be anything, but file extension will be .xls. If we need to read data from a specific Excel file name then we have to configure it accordingly.
  • Retrieve File Name: select the Fully Qualified radio button.

Then, create variable mappings for the Foreach Loop container, select the "User::FileName" variable and set the Index value to 0 in the Variable Mappings section.

Add a Data Flow Task inside the Foreach Loop Container. Right click on the recently added Data Flow task and click on Properties and mark the DelayValidation property to True.

Add an Excel Source in the Data Flow Task and create a new connection to any of the Excel source files.

You have to make the Excel connection dynamic so that it can connect to each Excel file in the source folder. To make the Excel source connection dynamic, right click on Excel Source Connection and then click on Properties.

Expand the Expression Properties, then select the Connection String property and then click on the expression icon, in the expression window :

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+@[User::FileName]+";Extended Properties="Excel 8.0;HDR=YES";"

Finally, execute the SSIS package and see the result.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...