recursive delete for a self-referenced table

  • I have a self referenced table and was wondering what the best way is to perform a recursive delete. The table is basically going to be used as a folder structure where one folder can have multiple folders under it and then multiple folders under that. I am unable to use a cascade delete here, so is there an easy way that if I delete a "folder" so to speak, all under it are also deleted?

  • Nick-260698 (5/21/2010)


    I have a self referenced table and was wondering what the best way is to perform a recursive delete. The table is basically going to be used as a folder structure where one folder can have multiple folders under it and then multiple folders under that. I am unable to use a cascade delete here, so is there an easy way that if I delete a "folder" so to speak, all under it are also deleted?

    Yes... but you need to post the data to be able to explain it. Please don't assume you know how to do that correctly, though. The data needs to be "readily consumable". Please see the article at the first link in my signature line for how to do that.

    --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)

  • What code would you like me to post? I have the tables/relationships however I have not even begun to tackle the recursion.

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

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