I need to remove nodes from XML.
I try to use UpdateXML function.
For example removing node C:
SELECT UpdateXML('<A><B>b_value<C>c_value1</C></B></A>', '/A/B/C', '')
Result:
'<A><B>b_value</B></A>'
But when in XML there are multiples matches, function returns the original xml:
SELECT UpdateXML('<A><B>b_value<C>c_value1</C><C>c_value2</C></B></A>', '/A/B/C', '')
Result:
'<A><B>b_value<C>c_value1</C><C>c_value2</C></B></A>'
But I need to get such result:
'<A><B>b_value</B></A>'
How I can remove all nodes when there are multiple matches.
A possible workaround is to use a stored procedure:
See db-fiddle.