Concat SQL中的两个XML字符串 [英] Concat two xml string in sql
本文介绍了Concat SQL中的两个XML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的输出中有两个Xml作为xml编辑器
I have two Xml in my output as xml editor
<Contact>
<PLate>
<PlateId>60</PlateId>
<ActionId>1</ActionId>
</PLate>
</Contact>
第二个是
and second one as
<Contact>
<PLate>
<PlateId>59</PlateId>
<ActionId>2</ActionId>
</PLate>
</Contact>
如何连接这两个xml以获得最终结果为
How to Concatenate this two xml to get final result as
<Contact>
<PLate>
<PlateId>60</PlateId>
<ActionId>1</ActionId>
</PLate>
</Contact>
<Contact>
<PLate>
<PlateId>59</PlateId>
<ActionId>2</ActionId>
</PLate>
</Contact>
推荐答案
您可以将其简单地转换为varchar(max)/nvarchar(max),进行连接,然后
放回去.
You can simply cast it to varchar(max)/nvarchar(max), concatenate and then
cast it back.
declare @x xml, @y xml
select @x = '<contact>
<plate>
<plateid>60</plateid>
<actionid>1</actionid>
</plate>
</contact>'
select @y = '<contact>
<plate>
<plateid>59</plateid>
<actionid>2</actionid>
</plate>
</contact>'
select cast(cast(@x as nvarchar(max)) + cast(@y as nvarchar(max)) as xml)
这篇关于Concat SQL中的两个XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文