title: How to query xml value inside a xml column in SQL server
body: <p>I have something like following code inside  [XMLValue] column of a table called "AlgorithmLog":  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;AdapterInfo xmlns:i="http://www.w3.org/2001/XMLSchema-instance"     
              xmlns:d1p1="http://schemas.datacontract.org/2004/07/Adapters.Adapter.CloudTrader"    
              xmlns="http://schemas.datacontract.org/2004/07/Adapters.Adapter"  
              i:type="d1p1:AlgorithmStatusReport"&gt;
      &lt;SequenceNumber&gt;0&lt;/SequenceNumber&gt;
      &lt;TrackingGuid i:nil="true" /&gt;
      &lt;d1p1:Broker&gt;Default&lt;/d1p1:Broker&gt;
      ...
         &lt;d1p1:XMLValue&gt;&amp;lt;?xml version="1.0"?&amp;gt;&amp;lt;int xmlns="http://schemas.microsoft.com/2003/10/Serialization/"&amp;gt;1900&amp;lt;/int&amp;gt;&lt;/d1p1:XMLValue&gt;
  &lt;/AdapterInfo&gt;
  </code></pre>
  
  <p>and I want to get the value "1900" inside the node <code>&lt;d1p1:XMLValue&gt;</code></p>
  
  <p>So here is my query:</p>
  
  <pre><code>WITH XMLNAMESPACES('http://schemas.datacontract.org/2004/07/Adapters.Adapter' AS x, 
                     'http://schemas.datacontract.org/2004/07/Adapters.Adapter.CloudTrader' As p,
                     'http://schemas.microsoft.com/2003/10/Serialization/'as w)
     SELECT  
         XMLValue.query('(/x:AdapterInfo/p:XMLValue/w:int)[1]')AS [XMLVaule]
     FROM AlgorithmLog 
  </code></pre>
  
  <p>But it returns nothing.</p>
  
  <p>Could anyone tell me where I did wrong or how I can do it?</p>
  
  <p>Thank you.</p>