prabhu sundararaj
prabhu sundararaj

Reputation: 15

How do i traverse files through folder using for loop container in SSIS

There are so many examples for traverse files through folder using foreach loop container but i want to know how to traverse files using For loop container please help me

Upvotes: 0

Views: 319

Answers (1)

Tab Alleman
Tab Alleman

Reputation: 31785

A For loop uses a range and a counter. If you wanted to use a For loop to traverse files in a folder, you would have to use a script task to count the number of files in the folder, and populate a variable with that number.

Then you would have to set a counter variable to 0, and set the For Loop to run while the counter is less than the file count, and increment the counter by 1 for each iteration.

Inside your loop you would need to get the file by its Index within the folder, presumably using the FileSystemObject in a Script Task.

Not particularly efficient, which is why the ForEach loop is usually used for files.

Upvotes: 1

Related Questions