Update XML stored in a XML column in SQL Server

前端 未结 2 1312
不知归路
不知归路 2021-01-12 12:23

I have a sample table in SQL Server 2012. I am running some queries against but the .modify() XQuery method is executing but not updating.

Here is the t

2条回答
  •  不知归路
    2021-01-12 12:55

    You should declare a namespace in your update syntax .Try the below syntax

    Declare @Sample table
    (xmlCol xml)
    
    Insert into @Sample
    values
    ('
            
                Name
            
          ')
     Select * from @Sample
     Update @Sample
     SET xmlCol.modify(
                      'declare namespace ns="http://www.w3.org/2001/XMLSchema";
                       replace value of (/ns:Doc/@Settings)[1]
                       with "NewTest"')
    
     Select * from @Sample
    

提交回复
热议问题