This question follows up this great answer: T-SQL XML Query, how to seperate matching nodes into individual rows? What if the values where:
<child>
<name>Fred</name>
<sname>Flintstone</name>
</child>
<child>
<name>Bill</name>
<sname>Gates</name>
</child>
And I wanted the output to be like:
Fred
Flintstone
Bill
Gates
Or even better, this:
name: Fred
sname: Flintstone
name: Bill
sname: Gates
(all in one column)
-->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:
I've figured it out! :-) So I'm obliged to share my own solution. Here it is:
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)
Thanks anyone for having a look at my question!