Query to Update exisiting XML node in SQL Server -


how replace node in xml column new value.

table :   create table erversion  (     erversionid    int,    change     xml    )  insert erversion  values   (123,'<changes><change property="custodian"><before>group ab</before><after>group ax</after></change></changes>')    go   insert erversion  values   (124,'<changes><change property="custodian"><before>group ax</before><after>group ab</after></change></changes>')   go select * erversion 

i need update values in xml column "change" new values
eg:
"group ab" "group1"
"group ax" "group2"...

this duplicate, please check existing answers searching.

you can find related question , answer here: update xml stored in xml column in sql server

succinctly:

update [tablename] set [xmlcolumn].modify('replace value of (/myxmldoc/@xmlproperty)[1] "newxmlvalue"') 

for complete reference of xml dml (data modification language) please view msdn documentation: http://technet.microsoft.com/en-us/library/ms177454.aspx


Comments

Popular posts from this blog

c# - OpenXML hanging while writing elements -

php - regexp cyrillic filename not matches -

sql - Select Query has unexpected multiple records (MS Access) -