This is my xml stored in an XML type column called UserDef
<Orders>
<Document>
<DocumentID>abc123</DocumentID>
<ActualShipDate />
<Comments/>
</Document>
<Document>
....
...
</Document>
</Orders>
I'm trying to populate the Comments
element with this:
declare @t1 table (id bigint, userdef xml)
insert into @t1
select id, userdef from MyMainTable
update @t1
set userdef.modify('replace value of(/Orders/Document/Comments[1]/text())[1] with "NO COMMENTS"')
select * from @t1
However, I don't see the Comments
being populated at all. What should I do differently in order for this to work?