For Each loop Question

  • Hello Everyone.

    I am new to SSIS. I am trying to create a package. I have serveral tables. Table Main, table2, ... tablexx from here I get My data. I also have table MainInsert, table2Insert.... tablexxInsert

    I Start by extracting my main Item from Table Main (KeyItem, this dictates what I will insert into all other tables). Based on that KeyItem I insert always into Table MainInsert, then with I query table 2, if there are records in this Item I want to Insert into to searching and inserting into other tables Otherwise I on

    1. Query my table Main and select all of the distinct key Items.

    2. Insert in table MainInsert certain fields determined by KeyItem

    3. Query table2 using Key Item.

    IF this table has records related to KeyItem THEN

    THEN insert into table2Insert

    Query Table3 Using KeyItem

    IF table3 has records related to KeyItem THEN

    Insert into table2Insert

    ELSE

    return to Main level to continue with next KeyItem

    ENDIF

    ELSE

    CONTINUE with then Next KeyItem

    ENDIF

    This about 6 if statements deep.

    I would appreciate any examples or any input about getting around this problem.

    Thank you

    Jesus I.

  • [font="Comic Sans MS"]

    Sorry Jibbara - I tired to go through the the statement few times and got lost somehow. Probably my bad ..

    Could you try to elaborate with some data perhaps?

    [/font]

    [font="Comic Sans MS"]--
    Sabya[/font]

  • What do you mean by 'certain fields determined by KeyItems'? are these input variables, or do you mean that each row determines what will be imported?

  • Also, a description of the business reasons for this package would help. Are all of these tables created just to manage your SSIS process or are these tables used by other applications/processes?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 4 posts - 1 through 3 (of 3 total)

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