0% found this document useful (0 votes)
18 views11 pages

Foreach Loop

The document outlines the process of creating a SQL table and configuring a Foreach Loop for data flow tasks. It includes steps for deleting existing data, setting up variables, and mapping parameters for SQL tasks. Additionally, it describes configuring file paths and handling errors in the data flow process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views11 pages

Foreach Loop

The document outlines the process of creating a SQL table and configuring a Foreach Loop for data flow tasks. It includes steps for deleting existing data, setting up variables, and mapping parameters for SQL tasks. Additionally, it describes configuring file paths and handling errors in the data flow process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

FOREACH LOOP

First we can create table

Creating table in sql:

create table dbo.empdata(empid int,empname varchar(100),empsalary money,

datadate date)

delete from dbo.empdata where datadate=convert(date,?)

next create variables for execute sql task:

add date expression in variables

(DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + "-" +

RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + "-" +

RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2)


we can check the date by this query

delete from dbo.empdata where datadate=convert(date,'2024-12-28')


And next check and give connection to sql task:

parameter mapping:
After this we can check sql task by using execute task(deleted current data)

For data flow task we need to give path in variables


Now configuring foreach loop

We are declaring folder as dynamically go to expression select directory and choose files dir
Next step is to configure dataflow task now we are giving source file details
And next destination for destination we only having 3 columns so we are using derived column for
fourth one
Noe the destination is also ready
Assign values to filedir
Same to error file

Next we need to keep delay validation true


Atlast we to give flat file connection dynamically

Last one event handler here we need to add propogate

Propogate : even the task is fails also it works

You might also like