【发布时间】:2010-09-05 09:25:44
【问题描述】:
我有一个结构如下的表:
| LocationID | AccountNumber |
|---|---|
| long-guid-here | 12345 |
| long-guid-here | 54321 |
要传递到另一个存储过程,我需要 XML 看起来像这样:
<root>
<clientID>12345</clientID>
<clientID>54321</clientID>
</root>
到目前为止,我能做的最好的事情就是这样:
<root clientID="10705"/>
我正在使用这个 SQL 语句:
SELECT
1 as tag,
null as parent,
AccountNumber as 'root!1!clientID'
FROM
Location.LocationMDAccount
WHERE
locationid = 'long-guid-here'
FOR XML EXPLICIT
到目前为止,我已经查看了the MSDN page 上的文档,但没有得到想要的结果。
@KG,
你的实际上给了我这个输出:
<root>
<Location.LocationMDAccount>
<clientId>10705</clientId>
</Location.LocationMDAccount>
</root>
我现在将坚持使用 Chris Leon 的 FOR XML EXPLICIT。
【问题讨论】:
标签: sql xml sql-server-2005 formatting for-xml