title: Iterate through XML variable in SQL Server whether what is in XML
body: <p>In SQL Server, how can I query the following XML</p>
  
  <pre><code>&lt;Employee&gt;
     &lt;FirstName&gt;David&lt;/FirstName&gt;
     &lt;LastName&gt;Jons&lt;/LastName&gt;
     &lt;Age&gt;28&lt;/Age&gt;
  &lt;/Employee&gt;
  &lt;Employee&gt;
     &lt;FirstName&gt;Eric&lt;/FirstName&gt;
     &lt;LastName&gt;Terry&lt;/LastName&gt;
     &lt;Age&gt;36&lt;/Age&gt;
  &lt;/Employee&gt;
  &lt;Employee&gt;
     &lt;FirstName&gt;Kady&lt;/FirstName&gt;
     &lt;LastName&gt;Campell&lt;/LastName&gt;
     &lt;Age&gt;21&lt;/Age&gt;
  &lt;/Employee&gt;
  </code></pre>
  
  <p>If the element names are the same, we can use the approach below: </p>
  
  <p><a href="https://stackoverflow.com/questions/16499268/iterate-through-xml-variable-in-sql-server">Iterate through XML variable in SQL Server</a></p>
  
  <p>Therefore, How to get the following result or something like that:</p>
  
  <pre><code>FirstName   |  LastName   | Age
  ----------- +-------------+-----
  David       |   Jons      | 28
  Eric        |   Terry     | 36
  Kady        |   Campell   | 21
  </code></pre>
  
  <p>given that I don't know the element name of the XML such as FisrtName, LastName, Age, <br></p>
  
  <p>I think I hope to get result like this SQL statement: </p>
  
  <pre><code>SELECT * FROM Employee
  </code></pre>
  
  <p>in which I don't know the column name of table <code>Employee</code></p>