因此,我从SQL Server 2000数据库中提取数据,然后使用FOR XML AUTO将其转换为XML。SQL Server FOR 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没有根( '无论'),所以是有任何方式在T-SQL中添加根节点?另外,是否有办法将所有产品包装在产品标签中?我不明白为什么返回的XML格式很糟糕。如果我在SQL 2005中,我可以修复它。不幸的是,我现在陷入了2000年。
感谢
甚至可以尝试SQL 2000链接... http://msdn.microsoft.com/en-us/library/aa226532(SQL.80).aspx – gbn 2009-08-14 18:42:43