Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server FOR XML adding in a tag
    primarykey
    data
    text
    <p>So I am pulling data from a SQL Server 2000 DB then converting it to XML using FOR XML AUTO.</p> <p>The XML I get back looks like this.</p> <pre><code>&lt;Order OrderNumber="2000004" DeliveryPickupCharge="5.9900" SalesTaxTotal="0.0000" SubTotal="0.0000" Total="5.9900"&gt; &lt;Customer FirstName="Anthony" LastName="Caporale"&gt; &lt;Product ProductName="Paper Towels"&gt; &lt;OrderItem ItemQuantity="1" ItemPrice="8.5900" Total="8.5900" /&gt; &lt;/Product&gt; &lt;Product ProductName="Bathroom Tissue - Giant Roll"&gt; &lt;OrderItem ItemQuantity="2" ItemPrice="7.1500" Total="14.3000" /&gt; &lt;/Product&gt; &lt;Product ProductName="Napkins - 1-Ply"&gt; &lt;OrderItem ItemQuantity="1" ItemPrice="3.4900" Total="3.4900" /&gt; &lt;/Product&gt; &lt;Product ProductName="Facial Tissues - 2-Ply - White"&gt; &lt;OrderItem ItemQuantity="2" ItemPrice="2.0500" Total="4.1000" /&gt; &lt;/Product&gt; &lt;Product ProductName="Anti-Perspirant &amp;amp; Deodorant - Ultra DryCool Rush"&gt; &lt;OrderItem ItemQuantity="2" ItemPrice="3.5900" Total="7.1800" /&gt; &lt;/Product&gt; &lt;Product ProductName="Flushable Wipes - Fresh Mates Cloths - Refill"&gt; &lt;OrderItem ItemQuantity="2" ItemPrice="2.9500" Total="5.9000" /&gt; &lt;/Product&gt; </code></pre> <p> </p> <p>Firstly, in 2000 there is no Root('whatever'), so is there any way to add a root node in the T-SQL? Also, is there a way to wrap all the products in a products tag? I don't quite get why the XML returned is in such bad form. I could fix it up a little if I was in SQL 2005. Unfortunately, I am stuck with 2000 at the moment.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload