Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge the two xml fragments into one?

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.

like image 649
ca9163d9 Avatar asked Mar 19 '12 21:03

ca9163d9


People also ask

How do I combine two XML files in SQL Server?

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 = ...

What is merger XML?

A complete toolkit for reliably merging multiple XML documents or datasets into a single file. XML Merge analyses the structure of your XML files to identify differences and apply sophisticated rules for automated merging.


1 Answers

OK, I found one way

select @a, @b for xml path ('')
like image 100
ca9163d9 Avatar answered Sep 30 '22 15:09

ca9163d9