Update XML stored in a XML column in SQL Server

前端 未结 2 1338
不知归路
不知归路 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:48

    Since there is a XML namespace (xmlns:dev="http://www.w3.org/2001/XMLSchema") in your XML document, you must inlcude that in your UPDATE statement!

    Try this:

    ;WITH XMLNAMESPACES(DEFAULT 'http://www.w3.org/2001/XMLSchema')
    UPDATE XmlTable
    SET XmlDocument.modify('replace value of (/Doc/@Settings)[1] with "NewTest"')
    WHERE XmlId = 1
    

提交回复
热议问题