Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Adjacent Model - Delete Node

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2008-06-26 : 14:34:51
Hello,

I am using an Adjacent Model to create a 4 level categories:
http://www.sqllessons.com/categories.html

When I delete a node I need to delete all nodes under it.

How can I do this?

Thanks,
Miguel

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-06-26 : 14:43:24
Read this link at the bottom of your referenced page and use the lft and rgt to delete
http://searchoracle.techtarget.com/tip/1,289483,sid41_gci1072361,00.html


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2008-06-26 : 15:50:47
You mean I should replace the Adjacency List Model by a Nested Sets?

I couldn't find any procedure to delete a node.
I am a little bit lost with this ...

Thanks,
Miguel
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-06-26 : 16:07:03
It like it better.

To delete a node and its children delete from table where lft >= @lft and @rgt
where @lft and @rgt are the lft and right of the topmost node to delete



"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page
   

- Advertisement -