I have the following value in an XML data type column of a SQL Server table:
<feed>
<schedule>
<arrivalSla dayOfWeek="monday" addDays="1" time="02:00:00"/>
<arrivalSla dayOfWeek="tuesday" addDays="1" time="02:00:00"/>
<arrivalSla dayOfWeek="wednesday" addDays="1" time="02:00:00"/>
<arrivalSla dayOfWeek="thursday" addDays="1" time="02:00:00"/>
<arrivalSla dayOfWeek="friday" addDays="3" time="12:45:00"/>
</schedule>
<assetCode value="FI" />
</feed>
I want to update the time attribute where dayOfWeek="friday"
to "11:00:00". I have tried various ways, including the following, but get an error of
XQuery [learnTheXML.xnlColumn.modify()]: The target of 'replace' must be at most one node, found 'element(arrivalSla,xdt:untyped) *'
UPDATE learnTheXML
SET xmlColumn.modify('replace value of (/feed/schedule/arrivalSla[@dayOfWeek="friday"]) with "11:00:00"')
WHERE id = 1
What am I doing wrong?
1条答案
按热度按时间ssm49v7z1#
You still need to provide a singleton value to update and also you need to tell it you want to update (presumably) the value of
time
: