SQL Server 2000 DBからデータを引き出し、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