I have a simple xml in a XML column
<Bands>
<Band>
<Name>beatles</Name>
<Num>4</Num>
<Score>5</Score>
</Band>
<Band>
<Name>doors</Name>
<Num>4</Num>
<Score>3</Score>
</Band>
</Bands>
I have managed to update the column with :
-----just update the name to the id)----
UPDATE tbl1
SET [myXml].modify('replace value of (/Bands/Band/Name/text())[1]
with sql:column("id")')
All fine.
Question #1
How can I use this query to udpate the value to id+"lalala"
:
UPDATE tbl1
SET [myXml].modify('replace value of (/Bands/Band/Name/text())[1]
with sql:column("id") + "lalala"')
Error = XQuery [tbl1.myXml.modify()]: The argument of '+' must be of a single numeric primitive type
Question #1
Let's say I Don't want to update first record ([1]
) , But I want to udpate
(the same update as above) only where score>4
.
I can write ofcourse in the xpath :
replace value of (/Bands/Band[Score>4]/Name/text())[1]
But I dont want to do it in the Xpath. Isn't there a Normal way of doing this with a Where
clause ?
something like :
UPDATE tbl1
SET [myXml].modify('replace value of (/Bands/Band/Name/text())[1]
with sql:column("id") where [...score>4...]')
[1]
thing ? Didn't they think that maybe i want to updatemore than 1 element
? – Kattiekatuscha