title: update xml value in xml column sql
body: <p>I've got the following snippet of an xml retrieved from an sql column.</p>
  
  <pre><code>&lt;ALT_CODE1&gt;4D000BF1S20&lt;/ALT_CODE1&gt;
  &lt;ALT_CODE2 /&gt;
  &lt;SERIAL_NO&gt;1450010010&lt;/SERIAL_NO&gt;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>SET @sqlSTR = '
  UPDATE ##t
  SET yourxml.modify(''replace value of (/LabelData/ALT_CODE2/text())[1] with ''''' + @Alt_Code2 + ''''''')
  WHERE rowId = 1';
  
  EXEC(@sqlSTR)
  </code></pre>