• I think your table definition and table data are wrong. Or may be I don't know in what case use your case.

    That's because in a normal situation that includes parent/child you must to have a primary key, and a parent key. (ColumnID, ParentColumnID)

    Your data has 2 parents for child 5 and 6. And I don't see a parent child relation, but a many to many relation. In your data you are limited to a max of 3 step cascade, in a relation (Id,parentId) you have unlimited steps.

    In the third output row, your result must to be 101/2/4-5, so I think your original approach is wrong.

    Anyway you can get your desired results making a cursor and building the output, but you gonna have problems like the third row

    regards

    Martin