<Component>
<Caption>2 7/8" x 1",Drill Collar,2 3/8 PAC</Caption>
<Description>2 7/8" x 1",Drill Collar,2 3/8 PAC</Description>
<Count>1</Count>
<Sections>
<Section>
<Material>Steel AISI 4145</Material>
<Connection>2 3/8 PAC</Connection>
<Weight>28.7197</Weight>
<Length>0.508</Length>
</Section>
<Section>
<Material>Steel AISI 4145</Material>
<Connection>NC50</Connection>
<Weight>28.7197</Weight>
<Length>0.508</Length>
</Section>
<Section>
<Material>Steel AISI 4145</Material>
<Connection>NC36</Connection>
<Weight>28.7197</Weight>
<Length>0.508</Length>
</Section>
</Sections>
</Component>
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.
DECLARE @MaxFeatures XML
SET @MaxFeatures = N'<MaxAllowableTorque>0</MaxAllowableTorque>
<MaxAllowableForce>0</MaxAllowableForce>'
Update Component
SET XMLDetails.modify('
insert sql:variable("@MaxFeatures")
after (/Component/Sections/Section/Length)[1]
')