【发布时间】:2010-11-19 17:59:27
【问题描述】:
所以我从 SQL Server 2000 数据库中提取数据,然后使用 FOR XML AUTO 将其转换为 XML。
我得到的 XML 是这样的。
<Order OrderNumber="2000004" DeliveryPickupCharge="5.9900" SalesTaxTotal="0.0000" SubTotal="0.0000" Total="5.9900">
<Customer FirstName="Anthony" LastName="Caporale">
<Product ProductName="Paper Towels">
<OrderItem ItemQuantity="1" ItemPrice="8.5900" Total="8.5900" />
</Product>
<Product ProductName="Bathroom Tissue - Giant Roll">
<OrderItem ItemQuantity="2" ItemPrice="7.1500" Total="14.3000" />
</Product>
<Product ProductName="Napkins - 1-Ply">
<OrderItem ItemQuantity="1" ItemPrice="3.4900" Total="3.4900" />
</Product>
<Product ProductName="Facial Tissues - 2-Ply - White">
<OrderItem ItemQuantity="2" ItemPrice="2.0500" Total="4.1000" />
</Product>
<Product ProductName="Anti-Perspirant & Deodorant - Ultra DryCool Rush">
<OrderItem ItemQuantity="2" ItemPrice="3.5900" Total="7.1800" />
</Product>
<Product ProductName="Flushable Wipes - Fresh Mates Cloths - Refill">
<OrderItem ItemQuantity="2" ItemPrice="2.9500" Total="5.9000" />
</Product>
首先,2000年没有Root('whatever'),那么有没有办法在T-SQL中添加根节点呢?另外,有没有办法将所有产品包装在产品标签中?我不太明白为什么返回的 XML 格式如此糟糕。如果我使用的是 SQL 2005,我可以稍微修复一下。不幸的是,我现在卡在 2000 上。
谢谢
【问题讨论】:
标签: sql-server xml sql-server-2000 for-xml