我想知道如何使用 xquery 更新 SQL Server 2005 中 XML 节点的部分文本
在下面的例子中,我想用“excellent”替换“very”这个词
declare @xml as xml
set @xml = '<root><info>well hello this is a very good example</info></root>'
declare @replacement as varchar(50)
set @replacement = 'excellent'
declare @search as varchar(50)
set @search = 'very'
set @xml.modify('replace value of (/root/info/text())[1]
with replace((/root/info/text())[1],sql:variable("@search"),sql:variable("@replacement"))'
)
select @xml
任何帮助,将不胜感激