我想在SQL Server 2008中对XML列中的所有行执行更新,仅替换特定xml节点中的子字符串。我对XML DML / XQuery等内容还不熟悉,无法弄清如何实现。
要更新的列中XML的示例:
<d>
<p n="Richedit01" t="System.String">
<v>
<p> <img border="0" alt="Football4" src="/$-1/football4.jpg" /> </p>
</v>
</p>
</d>
我想在所有行中将子字符串'src="/$-1/'的所有出现替换为'src="/$-1/file/'。
尝试过这个,但显然我无法像这样使用XPath replace函数:
UPDATE Translation
SET ContentData.modify('replace value of (d/p[@t=''System.String'']/v)[1] with (d/p[@t=''System.String'']/v[replace(.,''src="/$-1/'',''src="/$-1/file/'')]) ')