I cannot seem to get a [comma-]delimited string out of an XML doc using just SQL Server 2005 XQuery.
I have:
<AAA>
<Name>Name_A</Name>
<Value>Val_A</Value>
</AAA>
<AAA>
<Name>Name_B</Name>
<Value>Val_B</Value>
</AAA>
<AAA>
<Name>Name_C</Name>
<Value>Val_C</Value>
</AAA>
... (etc.)
… and would like to get Val_A,Val_B,Val_C... – a comma-delimited string.
I can convert to a table then back to string with FOR XML, but thought there is a direct way.
Thank you.
How about this – this will work for any number of
<AAA>nodes in an XML variable:Output is: