次のような 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 を使用する必要がありますか?