How to rename XML node name in a SQL Server

后端 未结 1 343
無奈伤痛
無奈伤痛 2021-01-20 19:24

I have on my database a table with one column storing XML data. Due to changes in the source code we want to rename one specific XML node name and XML namespace. Lets say th

相关标签:
1条回答
  • 2021-01-20 20:20

    I don't know if this is possible with XML DML

    It might work for you to use replace instead.

    update YourTable set
      XMLCol = replace(replace(cast(XMLCol as nvarchar(max)), 
                               '<MediaClass xmlns="MediaClass/1">', 
                               '<Book xmlns="Book/1">'), 
                       '</MediaClass>', 
                       '</Book>')
    
    0 讨论(0)
提交回复
热议问题