This scenario explains how to loop though the files one by one.

First step is to define few variables in the system
.bmp)
1. uVar_FolderNameOfFilesToBeProcessed : Points to the folder that is required to be processed.
2. uVar_SourceConStr_DataSource : File name and folder gets saved in on each loop
3. uVar_SourceFileExtention : Defines the file extension type
Next is the settings of the Loop
First ---
.bmp)
Second --
.bmp)
Next step the script setting
In this section I am going to make it easy, so I am going to use a message box to display the File and folder name.
.bmp)
Please Note: SSIS is not a front-end software, the message box is just for test purposes.
next click on the "Design Script" and enter the code....
Public Sub Main()
'
' Add your code here
'
MsgBox(Dts.Variables("uVar_SourceConStr_DataSource").Value.ToString)
Dts.TaskResult = Dts.Results.Success
End Sub
.bmp)
Testing Scenarios
Assuming that we have 2 types of file (1- Excel files 2- Text file) .....
.bmp)
---First test finding *.xls files
In the variable "uVar_SourceFileExtention" we have "*.xls", and in the folders and subfolders we have 2 excel files, once running the SSIS package from BIDS you'll get 2 message box one message for each loop as...
.bmp)
---Second test finding *.txt files
Change the variable "uVar_SourceFileExtension" to "*.txt", and run the package again in BIDS, you will have to get only one message.
.bmp)
---Third test finding files with a special extension *30.xls or File*.xls
In this case you will get the same message box as the first scenario except you will only get the first message, file “File20070930.xls”
I guess this is a very interesting and useful post about SSIS and many other utilities and complex relationship with databases and PL/SQL.
ReplyDeleteSSIS Postgresql Read