December 01, 2001 03:01 PM
Using a Recursive Trigger to Delete a Subtree
Rating:

(0)
SQL Server Magazine
InstantDoc ID #23123
Q. Listing 1 creates a table named Tree that represents a hierarchical structure, and Figure 1 shows the hierarchical relationships among the tree's nodes. When I delete a specific row, I want the operation also to delete the entire subtree (i.e., all of that node's children). For example, if I delete the row containing childid = 2, I want the rows with childids 5, 6, 7, and 8 to be deleted as well. And when I delete the row that has childid = 1, all rows should disappear. How can I achieve these results?
...
You must be a paid Professional Member to access this entire article.
Already a Professional Member? Please log in now: