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 - 2001-05-13 : 23:53:43
|
Jarrod writes "Shouldn't this be easy !
Platform = NT4 & SQL Svr 2000
A table holds a typical tree structure ;
MenuID ParentMenuID Title ====== ============ ===== 1 0 GrandFather 2 1 Father 3 2 Son ..etc (unlimited levels)
I want to write a query which would return an XML tree like so...
<Menu MenuID="1" ParentMenuID="0" Title="GrandFather"> <Menu MenuID="2" ParentMenuID="1" Title="Father"> <Menu MenuID="3" ParentMenuID="2" Title="Son"> </Menu> </Menu> </Menu>
So
Select 1 AS Tag, ParentMenuID AS Parent, Title AS [MENUITEM!1!Title] From tblMenu2 Where ParentMenuID = 0 Order By MenuID,ParentMenuID For XML Explicit
will NOT suffice because the tree will be ? nodes deep!
Can this be done and if so how." |
|
|
|
|
|