Foreach Loop Container: To Iterate over a directory to pick files.
Data Flow Task: To load data from the CSV (Flat File Source) to the
database table (OLE DB Destination).
Flat File Source: For text or csv files.
OLE DB Destination: To select the destination table which we want to populate with.
Steps
First Drag and drop a Foreach Loop Container from the container section of the SSIS toolbox.
Now double click on the Project.params in the solution Explorer and create a variable SourceFolder as string. In the value field type the path from which you want to pick the files. We are creating this path as a project parameter so that it can be configured after deployment.
Create a user variable by clicking on the Variables icon on the right and create CompleteSourceFilePath variable of type string. This variable will hold the value returned from the Foreach loop container.
Now Double click on the Foreach loop Container and select Collection on left hand side. On the right hand side select Foreach File Enumerator. Now for Expression click on the three dots on the right which will open a property editor select Directory in the property section and select @[$Project:SourceFolder] as its value. Click Ok.
In Foreach Loop Editor window for Files enter *.txt or *.csv whatever file extension is required.
On the left hand side of the Foreach Loop Editor select Variable Mappings, on the right select User::CompleteSourceFilePath which will automatically assigned Index 0. Click OK.
From the SSIS toolbox drag and drop Data Flow Task from the favorites section inside the Foreach Loop Container. Each file name returned by the Foreach loop container in CompleteSourceFilePath variable will be used in the data flow task.
Now double click on the Data Flow task which will take us into the Data flow. Drag and drop a Flat File Source from the other Source section of the toolbox.
At the bottom of the screen in Connection Managers section right click and then select New Flat File Connections. Click on the Browse button and select one of the file that you want to process, set other properties like Text qualifier (like double quote). Click OK.
Click on the new Flat file connection created in the connection Manager section and go the Properties window. Find the Expressions property and click on the three dots on the right. In the Property section select ConnectionString and in the Expression select the @[User::CompleteSourceFilePath] variable. Click OK.
Select a OLE DB Destination (according to the database) and configure it to the table that you want to load.
Right click on the package name (solution explorer) and click Execute package to test the package.