declare @xmlContent xml
set @xmlContent = '<book name="SQL Server 2005">
<author>张三</author>
<author></author>
</book>'
--更新属性
set @xmlContent.modify('
replace value of (/book/@name)[1]
with "SQL Server 2008"')
--更新一个有内容节点的内容
set @xmlContent.modify('
replace value of (/book/author[1]/text())[1]
with "李四"')
--更新一个无内容节点的内容,这里使用insert
set @xmlContent.modify('
insert text{"王五"}
into (/book/author[2])[1]')
select @xmlContent
SQL Server 更新xml列
最新推荐文章于 2023-07-07 15:36:40 发布
本文介绍如何使用SQL Server 2008中的XML数据类型进行属性及节点内容的更新操作,包括属性值替换、有内容节点内容替换以及无内容节点内容插入。
691

被折叠的 条评论
为什么被折叠?



