Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Need a Loop Within a Loop

Author  Topic 

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2013-10-02 : 22:24:07
hi all,
This is what I need to do:

1. Loop thru table rows which contain folder names, full paths to files and store that path into a variable
2. In a ForEach Loop, FTP each file in that folder (this is already working but only for a hard-coded folder path)

Go back and read the next row to get the next folder name.

I'm looking for ways of adding the Outer Loop for Step 1.

Thanks for any ideas. Jack


nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2013-10-03 : 03:49:29
Not sure what the problem is. Have a look at the for each item container. That allows a table as a source and place it in a variable.
Create a variable as a system object.
Create an execute sql task to get the full resultset from the table - just select the name. Under resultset set the resultset name to 0 and the variable to the one you have created.
That will populate the variable with the resultset.
Now create a for each loop with collection ADO enumerator and your object variable. Set the variable mapping to a string variable to get each value in turn.

That should give you a loop for each entry in the table.
I would then consider calling another package with that info to do the FTP using a variable with the path but that's up to you.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jbates99
Constraint Violating Yak Guru

396 Posts

Posted - 2013-10-03 : 08:35:03
Thanks for the ideas, Nigel. I will explore the ForEach Item loop.
Jack
Go to Top of Page
   

- Advertisement -