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 - 2005-02-24 : 07:45:29
|
| saravanane writes "Hi groups,I have a table named OfficeHierarchy where officeid and HeadOfficeid as columns and officeId is a Primary Key for that table.my table structure looks like this ---------------------------------officeId | headofficeid |----------------------------------chennai | bangalore |_________________________________Bangalore | Delhi |__________________________________Delhi | London |_________________________________London | France |----------------------------------Now i want my SQL query or a stored procedure should spot out all the Headoffice id's recursively.for an example,If my city is Bangalore ===> I should retrive its own HeadofficeId (Delhi) and inturn it should again retrive Delhi'sheadofficeId (London) and inturn it should again retrive London'sHeadofficeId (france) and France is the main officeid and it will not be present in the column officeid the query should result (for bangalore)* Delhi* London* francethank you in advance It's urgent Kindly Help me....E.saravananProgrammerIndigoTx" |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-24 : 08:04:28
|
There is a decent bit of info about trees here: http://www.seventhnight.com/treestructs.aspCorey "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
EugeneL
Starting Member
1 Post |
Posted - 2005-03-10 : 04:25:18
|
| this will help you:http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp |
 |
|
|
|
|
|