Merge the two xml fragments into one?

12,633

OK, I found one way

select @a, @b for xml path ('')
Share:
12,633
ca9163d9
Author by

ca9163d9

Updated on June 04, 2022

Comments

  • ca9163d9
    ca9163d9 almost 2 years

    How to merge the xml content of @a and @b into @c?

    declare @a xml = (select 1 aaa for xml path('AAAs'));
    declare @b xml = (select 1 bb1, 2 bb2 for xml path('BBBs'));
    declare @c xml = ... @a + @b ....?
    

    I need to pass the merged xml to a stored procedure.


    I know it's possible to cast the xml to varchar and concat them and convert it back to xml. Any better approach? The xml content can be big.