• There is absolutely nothing in your source data to guarantee the order of the data to do any batching or grouping with.  If this is actually starting out as a text file, please attach it along with a record layout and a target table and one of us might be able to show you how to pull this off.

    We also need to know the meaning behind the various Source_IDs and how many of each a "batch" can possibly have.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)