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