title: Selecting null value from XML in SQL Server
body: <p>I'm trying to select from XML that has a null as one of the attributes.  Instead of returning a null, it returns a 0.  What am I doing wrong?<br>
  See code below to replicate:</p>
  
  <pre><code>declare @a xml
  select @a = '&lt;TestSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instace"&gt;
    &lt;Element&gt;
      &lt;Property1&gt;1&lt;/Property1&gt;
      &lt;Property2&gt;1&lt;/Property2&gt;
    &lt;/Element&gt;
    &lt;Element&gt;
      &lt;Property1 xsi:nil="true" /&gt;
      &lt;Property2&gt;2&lt;/Property2&gt;
    &lt;/Element&gt;
    &lt;Element&gt;
      &lt;Property1&gt;3&lt;/Property1&gt;
      &lt;Property2&gt;3&lt;/Property2&gt;
    &lt;/Element&gt;
  &lt;/TestSet&gt;'
  
   select ParamValues.TaskChainerTask.query('Property1').value('.','int') as Property1,
          ParamValues.TaskChainerTask.query('Property2').value('.','int') as Property2
     from @a.nodes('(/TestSet/Element)') as ParamValues(TaskChainerTask)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>Property1   Property2
  1           1
  0           2
  3           3
  </code></pre>
  
  <p>This returns the same thing:</p>
  
  <pre><code>declare @a xml
  select @a = '&lt;TestSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instace"&gt;
    &lt;Element&gt;
      &lt;Property1&gt;1&lt;/Property1&gt;
      &lt;Property2&gt;1&lt;/Property2&gt;
    &lt;/Element&gt;
    &lt;Element&gt;
      &lt;Property1 xsi:nil="true" /&gt;
      &lt;Property2&gt;2&lt;/Property2&gt;
    &lt;/Element&gt;
    &lt;Element&gt;
      &lt;Property1&gt;3&lt;/Property1&gt;
      &lt;Property2&gt;3&lt;/Property2&gt;
    &lt;/Element&gt;
  &lt;/TestSet&gt;'
  
   select ParamValues.TaskChainerTask.query('Property1').value('.','int') as Property1,
          ParamValues.TaskChainerTask.query('Property2').value('.','int') as Property2
     from @a.nodes('(/TestSet/Element)') as ParamValues(TaskChainerTask)
  </code></pre>
  
  <p>Thanks in advance.    </p>