... small mistake: of course the ParentRegionID column should be:
ParentRegionID int null references Region(RegionID)
to cater for the "root(s)" of the tree.
This is a discussion on Tree structure data in xml .. - XML SOAP ; Hi, Can then "for xml" clause directly generate nested xml for data in a tree structure with arbirrary depth? E.G./ For a single region / sub-region table: create table Region (RegionID int identity(1,1) primary key, RegionName varchar(100) not null, ParentRegionID ...
Hi,
Can then "for xml" clause directly generate nested xml for data in a tree
structure with arbirrary depth?
E.G./ For a single region / sub-region table:
create table Region
(RegionID int identity(1,1) primary key,
RegionName varchar(100) not null,
ParentRegionID int references Region(RegionID)
)
Regards
Louis.
... small mistake: of course the ParentRegionID column should be:
ParentRegionID int null references Region(RegionID)
to cater for the "root(s)" of the tree.
In "What's New in FOR XML in Microsoft SQL Server 2005" -
http://msdn.microsoft.com/library/de.../forxml2k5.asp
Michael gives an example of using recursive T-SQL functions to achieve
nesting XML tags up to the nested function invocation limit (32 by default).
Look for "Recursion and FOR XML".
In SQL Server 2000 it is not possible. You can always resort to a client
side solution and reshape non-recursive XML produced on the server with
XSLT.
Best regards,
Eugene
---
This posting is provided "AS IS" with no warranties, and confers no rights.
"Louis Kriel" <ludez@bla> wrote in message
news:Oerkm6b5FHA.156@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> Can then "for xml" clause directly generate nested xml for data in a tree
> structure with arbirrary depth?
> E.G./ For a single region / sub-region table:
>
> create table Region
> (RegionID int identity(1,1) primary key,
> RegionName varchar(100) not null,
> ParentRegionID int references Region(RegionID)
> )
>
>
>
> Regards
> Louis.
>
>