更新时间:2022-03-26 06:58:55
可以将 XML 拆分为一个表变量,单独替换每个节点,然后再次合并.
You can split the XML to a table variable, replace each node separately and then combine them again.
declare @xml xml =
'<a abb="122">
<b></b>
</a>
<a abb="344">
<b></b>
</a>'
declare @T table (XMLCol xml)
insert into @T
select
a.query('.')
from @xml.nodes('a') a(a)
update @T set
XMLCol.modify('replace value of (/a/@abb)[1] with 888')
set @xml = (select XMLCol as [*]
from @T
for xml path(''))