SQL Server XML Replace values in attribute

后端 未结 2 1310
Happy的楠姐
Happy的楠姐 2020-12-21 23:54

I want to replace the value in an attribute in a XML. This attribute comes multiple times in the xml. How can i replace these all at once

my xml lools some what like

2条回答
  •  醉梦人生
    2020-12-22 00:17

    You can try the following. Here ns2zarejestrujStanZgodyAsync is main node and I have updated the value of idSystemy from 13 to 38.

    UPDATE @t
    SET yourXML.modify('replace value of 
    (/ns2zarejestrujStanZgodyAsync/rejestrujStanZgody/idSystemy/text())[1] with ("38")')
    

    You can check for demo here- XML Node Update

提交回复
热议问题