I went through all the various question pertaining to this topic, and I cant seem to find an answer in what is already provided.
What I am trying to do is insert a new node in the xml structure. When I run the below code, it doesnt shoot an error, but the XML doesn't not contain the newly inserted "material" sub section.
Would any of you mind pointing out where I am messing up here?
DECLARE @t TABLE (rowID int IDENTITY PRIMARY KEY, XmlData XML)
INSERT INTO @t (XmlData)
VALUES ('
<Root>
<ProductDescription ProductID="01" ProductName="Widget">
<Features>
<Warranty>1 year</Warranty>
<Maintenance>Monthly</Maintenance>
</Features>
</ProductDescription>
</Root>
')
UPDATE @t
SET XmlData.modify('insert <Material /> as first into (/Features)[1]')
SELECT 'before' s, DATALENGTH(XmlData) dl, XmlData
FROM @t
WHERE rowId = 1