I've got the following snippet of an xml retrieved from an sql column.
<ALT_CODE1>4D000BF1S20</ALT_CODE1>
<ALT_CODE2 />
<SERIAL_NO>1450010010</SERIAL_NO>
I'm trying to update the value of ALT_CODE2. When I use the following code it doesn't update the value of ALT_CODE2. I presume because there isn't a value present. How do I update / insert the value into ALT_CODE2 please:
SET @sqlSTR = '
UPDATE ##t
SET yourxml.modify(''replace value of (/LabelData/ALT_CODE2/text())[1] with ''''' + @Alt_Code2 + ''''''')
WHERE rowId = 1';
EXEC(@sqlSTR)