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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 XML hierarchy when the depth is unknown

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-05-20 : 22:50:15
Timothy writes "I have table "a" with key field "b" in it. I have another table "c" with a list of items in it, keyed on field "d".

Table "e" has a list of records linking items in "a" to Items in "c" in a parent field and a child field.

So you could potential have a item in table "a" with a child item which in turn could have a child item or sevaral child items which could also have child items as well. It theoretically go on and on with some items having many levels of hierarchy and others having just a few.

My question is this: How do I get a query on these items and linked items to produce xml that contains everything properly nested even if I do not know how deep the nests may go?

I am just getting into sql 2000 and am not sure the easiest way to accomplish this. In the past I would have just run loops through the data to figure out what goes with what but that seems like such a waste.

Thanks."
   

- Advertisement -