title: T-Sql xml query with namespace
body: <p>This is a follow up question to </p>
  
  <p><a href="https://stackoverflow.com/questions/8909711/t-sql-xml-query">T-Sql xml query</a></p>
  
  <p>If I add a namespace to xml data, nothing is returned again.</p>
  
  <pre><code>DECLARE @xVar XML
  SET @xVar = 
    '&lt;ReportData ObjectId="123" xmlns="http://ait.com/reportdata"&gt;
    &lt;ReportId&gt;AAAA-BBBB-CCCCC-DDDDD&lt;/ReportId&gt;
    &lt;DocId&gt;100&lt;/DocId&gt;
    &lt;ReportName&gt;Drag Scraper Troubleshooting&lt;/ReportName&gt;
    &lt;DocType&gt;Name&lt;/DocType&gt;
    &lt;StatusId&gt;1&lt;/StatusId&gt;
    &lt;AuthorId&gt;1&lt;/AuthorId&gt;
     &lt;/ReportData&gt;'
  
  SELECT [ReportId]= reportdata.item.value('.', 'varchar(40)') 
  FROM   @xVar.nodes('/ReportData/ReportId[1]') AS reportdata(item) 
  </code></pre>
  
  <p>The above query returns nothing. Secondly, how would I select all elements in a single select and return a row with all elements as fields?</p>
  
  <p>I want to return a record constructed as the following:</p>
  
  <pre><code>ReportId              | DocId | ReportName | 
  AAAA-BBBB-CCCCC-DDDDD | 100   | AAAA-BBBB-CCCCC-DDDDD |
  </code></pre>