title: T-SQL XML Query, how to separate matching nodes into individual rows? Part II
body: <p>This question follows up this great answer: <a href="https://stackoverflow.com/questions/2596904/t-sql-xml-query-how-to-seperate-matching-nodes-into-individual-rows/10451753#10451753">T-SQL XML Query, how to seperate matching nodes into individual rows?</a>
  What if the values where:</p>
  
  <pre><code>   &lt;child&gt;
      &lt;name&gt;Fred&lt;/name&gt;
      &lt;sname&gt;Flintstone&lt;/name&gt;
     &lt;/child&gt;
     &lt;child&gt;
      &lt;name&gt;Bill&lt;/name&gt;
      &lt;sname&gt;Gates&lt;/name&gt;
     &lt;/child&gt;
  </code></pre>
  
  <p>And I wanted the output to be like:</p>
  
  <pre><code>Fred
  Flintstone
  Bill
  Gates
  </code></pre>
  
  <p>Or even better, this:</p>
  
  <pre><code>name: Fred
  sname: Flintstone
  name: Bill
  sname: Gates
  </code></pre>
  
  <p>(all in one column)</p>
  
  <p>-->Since I can't answer my own question for the next 3 hours, I'll edit my question as suggested by stackoverflow. Here's my answer to my own question:</p>
  
  <p>I've figured it out! :-) So I'm obliged to share my own solution. Here it is:</p>
  
  <pre><code>SELECT
    distinct childs.value('fn:local-name(.)', 'nvarchar(50)') + '=' + childs.value('(text())[1]', 'varchar(50)') as Children
  FROM  
    #t CROSS APPLY
    data.nodes('//parent/child/*') AS Children(childs)  
  </code></pre>
  
  <p>Thanks anyone for having a look at my question!</p>