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.
| Author |
Topic |
|
madhulatha_b
Starting Member
22 Posts |
Posted - 2006-05-27 : 07:28:47
|
| I have two tables Node1,Treenode1 These two tables contains the project related informationProject Structure is Project|Area|Site|ProductThe structure of treenode isNodeIdNodeParentIDType..NodeId contains Id of the node like project,area etcNodeParentId contains ID of the Parent node.Type contains level of the nodeex: for project node there no parent so it will have NULL. For Area, Project NodeId become NodeparentID of Area and so onThe data in treenode will be in the following mannerNodeID NodeParentID TypeP1 Null 1 ----> ProjectA2 P1 2 ----> AreaA3 P1 2 -----> AreaS4 A2 3 ---->SiteS5 A2 3 ----> SiteS6 A3 3 ---->SiteS7 A3 3 ---->SiteR4 S4 4 ---->ProductR5 S5 4 ---->ProductR6 S6 4 ---->ProductR7 S7 4 ---->ProductNode1 contains only Project related recordsTreenode contains Project and child records i.e project,area,site and product detailsNow I want to delete all projects which are older than one year. For that I need to delete records from node1 and treenodefor that First I am fetching the records from node1select Node into #NA1 from node1 where datediff(day,project_Releasedate,getdate()) > 365 Based on #NA1 I am fetching the project details from treenodeselect NodeID,NODEparentID,type into #tmp_treenode from treenode where NODEID in (select node from #NA1) I have project records in #treenode. Now I need to fetch child records from treenode.Is it possible to fetch all child records using single query |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|