• Seems like further clarification of the needs is required. Should "chained" intersections be allowed/considered as one group? Or discarded.

    I also note that the cursor version for your data returns:

    ShapeID GroupID

    ------- -------

    A1B20 1

    D1B19 1

    E3A22 2

    C5B23 3

    A1B11 3

    D1B25 4

    Since D1B19 and E3A22 intersect, it would seem apparent that a modification to the code would be required to make the output actually put BOTH of those in the same group, i.e.

    ShapeID GroupID

    ------- -------

    A1B20 1

    D1B19 1

    D1B19 2

    E3A22 2

    C5B23 3

    A1B11 3

    D1B25 4

    Again, some logic requirements are needed for muti-grouping (such as happens for D1B19 here).

    OP, what is the actual and complete desired effect of this new set of inputs??

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service