Is there any way to combine these two replace values with 1 update statement?
UPDATE dbo.MyTable
SET MyXmlColumn.modify('replace value of (/node/@att1)[1] with "1"')
WHERE id = 1
UPDATE dbo.MyTable
SET MyXmlColumn.modify('replace value of (/node/@att2)[1] with "2"')
WHERE id = 1
http://msdn.microsoft.com/en-US/library/ms190675(v=SQL.90).aspx
I dont think you’re in luck, Thx.
I tried several syntactical variants with no joy. For example, the obvious:
yields:
But there’s nothing helpful for this error message in the XML DML space.
The bottom line is that Expression1 & Expression2 must be single elements.
Even the most thorough discussions end up looping through it…
http://blogs.msdn.com/b/denisruc/archive/2005/09/19/471562.aspx
Sorry. 🙁
PS: If you can stand the hackiness, casting to VARCHAR(MAX) then doing a normal REPLACE() should do the trick. See: Can I do a find/replace in t-sql?