Note that there are some explanatory texts on larger screens.

plurals
  1. POXML DML for 2008 R2..How to modify nested Elements
    primarykey
    data
    text
    <pre><code> &lt;Component&gt; &lt;Caption&gt;2 7/8" x 1",Drill Collar,2 3/8 PAC&lt;/Caption&gt; &lt;Description&gt;2 7/8" x 1",Drill Collar,2 3/8 PAC&lt;/Description&gt; &lt;Count&gt;1&lt;/Count&gt; &lt;Sections&gt; &lt;Section&gt; &lt;Material&gt;Steel AISI 4145&lt;/Material&gt; &lt;Connection&gt;2 3/8 PAC&lt;/Connection&gt; &lt;Weight&gt;28.7197&lt;/Weight&gt; &lt;Length&gt;0.508&lt;/Length&gt; &lt;/Section&gt; &lt;Section&gt; &lt;Material&gt;Steel AISI 4145&lt;/Material&gt; &lt;Connection&gt;NC50&lt;/Connection&gt; &lt;Weight&gt;28.7197&lt;/Weight&gt; &lt;Length&gt;0.508&lt;/Length&gt; &lt;/Section&gt; &lt;Section&gt; &lt;Material&gt;Steel AISI 4145&lt;/Material&gt; &lt;Connection&gt;NC36&lt;/Connection&gt; &lt;Weight&gt;28.7197&lt;/Weight&gt; &lt;Length&gt;0.508&lt;/Length&gt; &lt;/Section&gt; &lt;/Sections&gt; &lt;/Component&gt; </code></pre> <p>I have a Component table in SQLServer 2008 R2 that has a PK ID field and another column of type XML. In that XML column I have XML that looks like what you see above. For each row, I want to modify all of the nested Section blocks so they each have two additional Elements. This is what I've tried and it only inserts the new elements into the first Section block...but not the other two.</p> <pre><code>DECLARE @MaxFeatures XML SET @MaxFeatures = N'&lt;MaxAllowableTorque&gt;0&lt;/MaxAllowableTorque&gt; &lt;MaxAllowableForce&gt;0&lt;/MaxAllowableForce&gt;' Update Component SET XMLDetails.modify(' insert sql:variable("@MaxFeatures") after (/Component/Sections/Section/Length)[1] ') </code></pre>
    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.
 

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