• Yes - I have a suggestion. Read the article I link to in my signature.

    I can guarantee that you do NOT want to loop through the tables. Whatever you are trying to accomplish will most likely be accomplished using joins, as in:

    SELECT {columns}

    FROM table1 t1

    INNER JOIN table2 t2 ON t2.key = t1.key

    INNER JOIN table3 t3 ON t3.key = t2.key -- or would this be related back to t1?

    WHERE {criteria to filter the results}

    Looping in SQL is almost always the wrong way to do get the job done.

    Again, review the article in my signature and see if you can post an example we can work with.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs