693579551 发表于 2016-10-29 11:35:23

SQL Server 更新xml列

declare @xmlContent xml
set @xmlContent = '<book name="SQL Server 2005">
<author>张三</author>
<author></author>
</book>'
--更新属性
set @xmlContent.modify('
replace value of (/book/@name)
with "SQL Server 2008"')
--更新一个有内容节点的内容
set @xmlContent.modify('
replace value of (/book/author/text())
with "李四"')
--更新一个无内容节点的内容,这里使用insert
set @xmlContent.modify('
insert text{"王五"}
into (/book/author)')
select @xmlContent
页: [1]
查看完整版本: SQL Server 更新xml列