title: SQL Server - Query XML Column with Missing Namespace
body: <p>This problem is really nasty it seems. I have the following small XML in a column named, "Message", and I'd like to query against it. The problem I'm having is with the "ClaimData" element. As you can see, it sets its namespace to an empty string.</p>
  
  <pre><code>&lt;DataExchange xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://schemas.abc.com/library/DataExchange"&gt;
    &lt;Data&gt;
        &lt;ClaimData xmlns=""&gt;
            &lt;CurrentClaimNumber&gt;TEST0000319001&lt;/CurrentClaimNumber&gt;
        &lt;/ClaimData&gt;
    &lt;/Data&gt;
  &lt;/DataExchange&gt;      
  </code></pre>
  
  <p>The query below is returning NULL values for the XML column because the ClaimData element uses an empty namespace, and I do not know how to indicate this in the query of the XML column.</p>
  
  <p>Can someone give a working (and hopefully, tested) example of how to query the "CurrentClaimNumber" element (which is a child of "ClaimData") in the XML Message column?</p>
  
  <p>Thanks very, very much.</p>
  
  <pre><code>WITH XMLNAMESPACES (
       'http://www.w3.org/2001/XMLSchema' AS "xsd",
      'http://www.w3.org/2001/XMLSchema-instance' AS "xsi",
       DEFAULT 'http://schemas.rising.com/library/DataExchange'
  ) SELECT [StoredMessageID],
      Message.value('(/DataExchange/Data/ClaimData/CurrentClaimNumber)[1]', 'CHAR(750)')
    FROM [DataExchange].[dbo].[MessageStorage]
  </code></pre>