2
votes

Hi I have one doubt in ssis,

how to load multiple source folders related files into destionation table using single foreachloop ssis package.

source files are available in two different folder and all files related structure is same in the both folder. source file have paths : c:\chenlocation\ in the source path have files like : emp.txt,emp1.txt,emp2.txt c:\punelocation\ in the source path have files like : emp_pune.txt,emp_pune1.txt,emp_pune2.txt,emp_pune4.txt.

in the two source path (chenandpunelocation paths)all files structure are same and look like columns id,name,sal. destination table (sql server ) is : emp and columns are same id,name,sal

in ssis package I have implemented like below : declare variables :

chenlocationpath : c:\chenlocation\ filename : emp.txt punelocationpath : c:\punelocation\

afte that drag and drop foreachloop conatiner and type >foreachfileenumerator>directory >checnloationpath variable>filetype>*.txt

variable mapping >filename variable. after that drag and drop dft task and confiugre flatfile source and change that datatype after that destination sql server table is configured.

after that again drag and drop 2nd foreachloop container and type >foreachfileenumerator>directory >punelocationpath variable>filetype>*.txt

variable mapping >filename variable. after that drag and drop dft task and confiugre flatfile source and change that datatype after that destination sql server table is configured. after exectuction all records are loaded in the destination table without failure.

here I have used 2 foreachloop tasks to process two different source path . I want to impleemnt single foreachloop with two different folder path into destination table

can you please tell me how to load two different path of source files data into destination table using single foreachloop container in ssis package .

1

1 Answers

0
votes

Assuming you have a list of your folders, just create a foreach loop that iterates over that list of folders and put your current loop inside, taking the current folder value as its source directory. On execution, this will then load each file in each folder in turn just as your current process does.