SQL Server以在标签中添加XML
-
16-09-2019 - |
题
所以,我从SQL Server中提取数据2000 DB然后使用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没有根(“无论”),所以是有任何方式在T-SQL中添加根节点?此外,有没有一种方法来包装在产品标签所有的产品?我不太明白为什么返回的XML是在这样恶劣的形式。我可以修复它了一点,如果我是在2005年的SQL不幸的是,我坚持与2000年的时刻。
由于
解决方案
其他提示
我知道在2005年使用嵌套的选择可以让您嵌入一个核心标签与ensted seelect也被宣布为XML AUTO多个结果(在产品的多个产品)。
您还可以通过使用使用这种技术在根标记来包装一切一个大的嵌套选择。
不隶属于 StackOverflow