Updating XML using attribute to identify value in SQL server
Posted
by Tadhg
on Stack Overflow
See other posts from Stack Overflow
or by Tadhg
Published on 2010-06-17T08:50:51Z
Indexed on
2010/06/17
9:03 UTC
Read the original article
Hit count: 212
Xml
|sql-server-2005
I have a XML structure in a XML column on a SQL Server table as follows:
<Customizations>
<Customization name="OtherValue">
<value>Test</value>
</Customization>
. . . .
<Customization name="Year">
<value>2009</value>
</Customization>
</Customizations>
and I'm looking to update the value of Customization with the element with the attribute Year. Been looking at this for a while and best attempt is:
UPDATE TestTable
SET XmlColumn.modify(
'
replace value of (/Customizations/Customization/@name[.="Year"]/value)[1]
with ( "2010" )
')
Can someone help point out where I'm going wrong?
© Stack Overflow or respective owner