J'ai une table SQL Server 2005 comme ceci:TSQL: Comment faire une auto-jointure en XML pour obtenir un document imbriqué?
create table Taxonomy(
CategoryId integer primary key,
ParentCategoryId integer references Taxonomy(CategoryId),
CategoryDescription varchar(50)
)
avec des données ressemblant à CategoryIdParentCategoryIdCategoryDescription 123nullfoo345123bar
Je voudrais l'interroger dans un document XML comme ceci:
<taxonomy>
<category categoryid="123" categorydescription="foo">
<category id="455" categorydescription="bar"/>
</category>
</taxonomy>
Est-ce possible? avec FOR XML AUTO, ELEMENTS? Ou dois-je utiliser FOR XML EXPLICIT?