I have three XML columns in my SQL Table (single row table just used for storing XML) and the XML structure is something like this:
In Column 1 –
<Column1XML>
....
</Column1XML>
In Column 2 –
<Column2XML>
....
</Column2XML>
In Column 3 –
<Column3XML>
....
</Column3XML>
The final resultant XML that I am looking for is:
<SomeTagName>
<Column1XML>
....
</Column1XML>
<Column2XML>
....
</Column2XML>
<Column3XML>
....
</Column3XML>
</SomeTagName>
How can I obtain this required structure without doing string concatenation? I am sure there must be a way out with Typed XML.
Thanks in advance for looking up my question.
Here are two ways for you.
Sample data
Use the root name as column alias
Use
*as column alias and specify apath().Result: