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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-11-03 : 07:46:02
|
| Donnie Carvajal writes "I have a parent child relationship using 1 table:TABLEID intName VARCHAR(50)ParentID intWhere the ID and ParentID are related.I understand how to get the full tree using a recursive join. The problem that I am having has to do with pin pointing a node. Lets say I want to get all of the child nodes of parent with ID 1. Is there a way to gather this information using 1 query.Thanks." |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-11-03 : 09:50:24
|
| create table #rr (p varchar(8), c varchar(8))insert into #rrselect 'a', 'b' union allselect 'a', 'c' union allselect 'a', 'd' union allselect 'b', 'e' union allselect 'k', 'z' union allselect 'p', 'q' union allselect 'b', 'f'godeclare @s varchar(8000) set @s='a'select @s=@s+case when charindex(p, @s)>0 then c else '' endfrom #rrprint 'Papa and his children: ' + @sdrop table #rr |
 |
|
|
|
|
|