ssis nested for each loop

  • I am using 2 loops nested within each other to create connection strings to all of our databases on multiple instances. The outer loop uses foreach item enumerator to hard code the instance names and the inner loop uses the foreach ado enumerator to loop through the databases on each instance. Does anybody know of a good post (with pictures) of how to nested loops like this?

  • I don't have pictures, but isn't it just a matter of dragging and dropping the icons in the right place on the screen?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • please only constructive comments. 🙂

  • That was a constructive comment, in my opinion. Perhaps a little terse.

    It seems that you already know exactly what you want to do and how it should be implemented. I am assuming that you also know how to nest one foreach container within another - which really is as simple as clicking and dragging.

    So it's a bit unclear which bit you really need help with. Is it in setting up the collections?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • It is nice to know someone else out there is working on something similar to what I am working on. Please see my sample attached. I hope it helps.

    May your fish always be bigger
    Than the holes on your net.

  • george.auckland (4/23/2009)


    please only constructive comments. 🙂

    I'm sorry you found my question destructive, or whatever. I'm just trying to understand what you need. When I've nested loops in SSIS, I've just done the drag-and-drop thing. I've done this in several packages, and it's worked each time. So, I'm asking why it requires something more in your case, on the assumption that you might be doing something more complex than what it looks like.

    I often find, when something seems to be too simple to ask about, and I answer the literal question, that there's more to it than originally met the eye.

    If I'm wrong, and you need video instructions on how to drag-and-drop, I appologize. I don't have such, but I'm sure they can be created easily enough.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • thanks for the resonse ruizeddy.

  • hello ruizeddy,

    This is gonna work perfectly, many thanks. One question. You are using the datasource MSSQL_DB to loop through everything. Did you set that up through the gui, and did you need to enter any expressions (ie the variable name) to get it to work.

  • The connection was set up with the gui through the new connections option of the "(connect to server and Get databases)" Execute sql task. You can specify the local server as the default server. The only thing that changes in this object is the connection string (done by the "Change connection to currentserver" script task).

    May your fish always be bigger
    Than the holes on your net.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply