You have several problems:
- you're totally ignoring the XML namespace on the XML document in question (in your original
UPDATE
) - you're using an incomplete XPath expression for your modify
Try this statement:
;WITH XMLNamespaces(DEFAULT 'http://mynamespace.com/')
UPDATE dbo.MyTable
SET Info.modify('replace value of (/CodesParameter/Data[1]/@Code)[1] with ("B1")')
WHERE Id = 1
Basically, you need to start at the root of the XML document - you've missed (or left out) the <CodesParameter>
node entirely. Also: you need to select a single attribute - thus you need another [1]
after your parenthesis.
With this statement, I was able to update the XML as desired.