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 |
|
edp33
Starting Member
9 Posts |
Posted - 2007-03-09 : 06:40:03
|
| I am trying to traverse a tree structure like below, 1 Pets--1.1 Cat----1.1.1 Persian----1.1.2 Bengal--1.2 Dog ----1.2.1 Poodle2 etcI would like to be able to search by a keyword, i.e. Poodle, or the reference number, i.e. 1.2.1. I would prefer to do this all through a stored procedure if possible, it seems recursion is the way to go as the number of levels may increase in the future but i'm completely new to this. From what i've seen so far I would need a table structure with a parentID,NodeID,Name field and Primary key. i.e,ID...Name......Parent.....NodeID1....Pets.........0............12....Cat..........1............13....Dog..........1............14....Persian.....2............15....Bengal......2............26....Poodle......3............1etci've heard that SQL SERVER 2005 provides recursion through CTE, is this the recommended way/only way to achieve this?Any tips on where to start would be really appreciated. |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2007-03-09 : 09:28:13
|
| this has been discussed before and probably posted on the weblogsdo a search over theregood luck!--------------------keeping it simple... |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
|
|
|
|
|