Click here to Skip to main content
15,900,713 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,


I am using treeview control and wanted to delete the records from the relation table.

I am having table structure like this

Node id      Parent id

1		0
2		1
3		1
4		2
5		3
6		4
7		5


If I select 1st Node(is 0 i.e. Root node) then I want to delete all the records from the database

Thanks
Sjs4u
Posted
Updated 18-Sep-11 21:22pm
v2
Comments
Prerak Patel 19-Sep-11 3:22am    
Added text block

Implementing tree structures in a database is not recommended because of recursion and performance issues, but here are a few good links :

Adjacency List Model

Managing Hierarchical Data in MySQL

Trees and Other Hierarchies in MySQL
 
Share this answer
 
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_TreeNode_select]
@TreeNodeID INT
AS
BEGIN
SET NOCOUNT ON;

BEGIN
SELECT TreeNodeID
, ISNULL(ParentNodeID, 0) ParentNodeID
, Title
FROM [dbo].[TreeNode]
WHERE (@TreeNodeID = 0 OR TreeNodeID = @TreeNodeID)
ORDER BY ParentNodeID, TreeNodeID
END
END

/*** STORED PROCEDURE 3 ***/

u can find all child corresponding node then delete query Fire From According to TreeNode Id
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900