我有一个名为 StoreFolder 的表,其中包含一个名为 FolderXml 的 XML 字段。每行包含一个 XML 值,如下所示:
<Folder FolderName="test" StoreName="TestStore" />
我需要获取以下 XML 格式的文件夹:
<Folders>
<Folder FolderName="test1" StoreName="TestStore1" />
<Folder FolderName="test2" StoreName="TestStore1" />
<Folder FolderName="test3" StoreName="TestStore1" />
</Folders>
我尝试使用以下 SQL 语句:
SELECT FolderXml
FROM StoreFolder
FOR XML PATH(''), ROOT('Folders')
但它输出以下 XML:
<Folders>
<FolderXml>
<Folder FolderName="test1" StoreName="TestStore1" />
</FolderXml>
<FolderXml>
<Folder FolderName="test2" StoreName="TestStore1" />
</FolderXml>
<FolderXml>
<Folder FolderName="test3" StoreName="TestStore1" />
</FolderXml>
</Folders>
有人可以告诉我如何获取以下格式的 XML(使用 T-SQL):
<Folders>
<Folder FolderName="test1" StoreName="TestStore1" />
<Folder FolderName="test2" StoreName="TestStore1" />
<Folder FolderName="test3" StoreName="TestStore1" />
</Folders>
非常感谢