Showing posts with label looping. Show all posts
Showing posts with label looping. Show all posts

Thursday, March 29, 2012

ForEachLoop Container - How to Force Next Iteration -

How can I force a Next Iteration in a ForEach Loop container?

I am looping through a folder(ForEach Loop Container) looking for a specific File Name ( Child 'Script Task') to evaluate name).

If the current file is not the File Name I need, get the next file, other wise drop down to a Exec Proc task.

Is it possible to force "Next Interation' on the parent container?

Thanks - Covi

Not quite sure what you mean. In what circumstances do you want to 'force teh next iteration'?

-Jamie

sql

Tuesday, March 27, 2012

Foreach Loop is killing me!!!!!!!!!!!!!!!!!!!!!!

I would like your help with the Foreach loop container. Boy, am I having issues with using it for looping through an ADO.NET dataset or what!?!? My control flow has a data flow task that is executing a Data Reader task (creating a .NET dataset for me). Now I go back to the control flow and add a Foreach loop container to loop through each record in my dataset. But which type of the Foreach loop container should I be using? I see an option to use Foreach ADO.NET schema enumerator but not sure how to configure it. Also I used the Foreach ADO option, but setting up variables to go through every column is an absolute pain in the you know what!!?!! I have about 200 columns and I want an easier way to refer to those columns in my transformation phase.

Hope you are able to help me out here.

Jamie posted an answer on another thread!!?!!?!!?!!?!!!!!!!!?!!!!!

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=424137&SiteID=1

Monday, March 26, 2012

Foreach Loop - Value back to 0

Hi,

Let's say you have a Data Flow Task that connects to a Foreach Loop, looping through the data.

Somewhere inside the Foreach Loop, you set an int variable MyInt to a value.

My question:

Is it possable when each iteration begins to set MyInt to 0?

Thanks in advance.

Is the foreach loop evaluating the same variable, or are you using the variable for something else?

Script tasks can assign values to variables.|||Can you set a value of a variable inside an expression?|||

MrHat wrote:

Can you set a value of a variable inside an expression?

No.|||But you could set it by running "SELECT ? = 0" inside an Execute SQL task at the start of your loop, and assigning that output parameter to your variable.

Monday, March 12, 2012

For/Foreach loop

Hi,

I'm looping through some query data and doing a Script Task check inside the loop on a datetime field.

If the datetime happens before 10 o'clock:

- Store the data row in Table1

If the datetime happens after 10 o'clock:

- Store the data row in Table2

How can I store the datarow inside the loop without inserting it into a database table?

I need to access the data in the next step after the loop. How can I do this?

Thank you very much! Smile

Can you store the values in some variables?

|||

Thanks for the reply.

Yes, I could. But if I'm looping through 100 lines of query data, and I want to store 50 of them, wouldn′t it mean a whole lot of variables to store all the data?

Am I misunderstanding you perhaps?

|||If you have a single source connection for the data and you want to split the rows based on the value of a certain column, used a conditional split, as per previous post, and then write the rows to a raw file for later use.

Other option would be to generate the rows based on the conditions and then write them to variables, as per Jamie's option, and use them later.

Depending on the number of rows and different conditions you have, either option would work. Variable route may give performance / resource problems on large numbers though.|||

MrHat wrote:

Thanks for the reply.

Yes, I could. But if I'm looping through 100 lines of query data, and I want to store 50 of them, wouldn′t it mean a whole lot of variables to store all the data?

Yes it would. Is that a problem?

MrHat wrote:

Am I misunderstanding you perhaps?

I don't think so

-Jamie