In SQL I have no experience with XML columns and values.
I need to update (with a SQL query) the
<row note="49"> deadline detail</row>
to read:
<row note="49"> Deadline Balance</row>
There are multiple notes with different ids, in my case I only have to modify the one with id 49.
The structure of the column is this:
<rows>
<row nota="2">Contratto depositato [...] :-) </row>
<row nota="3">
Gli è stata concessa una dilazione.
Porre attenzione alle condizioni.
</row>
<row nota="49">deadline details</row>
</rows>
I tried this :
UPDATE CF
SET NoteXML.modify('replace value of (/rows/row[@nota="49"]/text())[1] with "deadline detail"')
WHERE Cd_CF = 'C000001'
And this is the error I get:
XQuery [CF.NoteXML.modify()]: The operator could not be applied "=" to the operands "xs:unsignedInt" and "xs:string".
2条答案
按热度按时间ztigrdn81#
It seems to be working.
SQL
Output
ibrsph3r2#
You can cast the @nota attribute to an integer in your XQuery expression. Here's the modified query:
Or else you can explicitly cast the @nota to a string by using below query