3
我有一個SQL Server 2005的表是這樣的:TSQL:如何在XML中進行自連接以獲取嵌套文檔?
create table Taxonomy(
CategoryId integer primary key,
ParentCategoryId integer references Taxonomy(CategoryId),
CategoryDescription varchar(50)
)
數據看上去就像 CategoryIdParentCategoryIdCategoryDescription 123nullfoo345123bar
我想它查詢到這樣一個XML文檔:
<taxonomy>
<category categoryid="123" categorydescription="foo">
<category id="455" categorydescription="bar"/>
</category>
</taxonomy>
是否可以這樣做使用FOR XML AUTO,ELEMENTS?或者我需要使用FOR XML EXPLICIT?