我有一个这样的 SQL Server 2005 表:
create table Taxonomy(
CategoryId integer primary key,
ParentCategoryId integer references Taxonomy(CategoryId),
CategoryDescription varchar(50)
)
数据看起来像
CategoryIdParentCategoryIdCategoryDescription
123nullfoo345123bar
I'd like to query it into an xml document like this:
<taxonomy>
<category categoryid="123" categorydescription="foo">
<category id="455" categorydescription="bar"/>
</category>
</taxonomy>
FOR XML AUTO, ELEMENTS 可以做到这一点吗?还是我需要使用 FOR XML EXPLICIT?