title: How to add or change an Xml namespace in SQL Server / Cannot use 'xmlns' in the name expression
body: <p>I have a XML column that is not generated with a namespace, meaning no xmlns attribute. Unfortunately, I cannot fix the actual problem, meaning where the XML is created.  </p>
  
  <p>For example:</p>
  
  <pre><code>&lt;root&gt;Our Content&lt;/root&gt;
  </code></pre>
  
  <p>I <em>can</em> modify the XML data before it's returned to a particular client that expects a namespace. What I want is pretty simple:</p>
  
  <pre><code>&lt;root xmlns="http://OurNamespace"&gt;Our Content&lt;/root&gt;
  </code></pre>
  
  <p>I tried something like:</p>
  
  <pre><code>.modify('insert attribute xmlns {"ournamespace"}...
  </code></pre>
  
  <p>But that errors with </p>
  
  <blockquote>
    <p>Cannot use 'xmlns' in the name expression.</p>
  </blockquote>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Is there a technique around this particular error?</li>
  <li>Is there an alternative or better way to add/change a namespace on a SQL XML type?</li>
  </ol>
  
  <p>This is in a SQL Server 2012 stored procedure.</p>