declare @xmlDoc xml
declare @PrintValue nvarchar(max)
select @xmlDoc=DESCRIPTION from dbo.WF_PERSIST_DESCRIPTOR where [PROCESS_ID]='1e9e9059-50ea-adac-4660-918cd54e3436' --将数据中的数据读取出来,数据库里面报错的是nvarchar(max)这里可以直接转换
set @xmlDoc.modify('replace value of (/Process/Activities/Activity[@key="N8"]/Name/text())[1] with "国美在线COO"') --替换掉某个节点下面的value值。 text() 是读取节点存储的text值
update dbo.WF_PERSIST_DESCRIPTOR set DESCRIPTION=Convert(nvarchar(max),@xmldoc) where [PROCESS_ID]='1e9e9059-50ea-adac-4660-918cd54e3436'
set @PrintValue=@xmlDoc.value('(/Process/Activities/Activity[@key="N8"]/Name)[1]','nvarchar(MAX)')
print @PrintValue
declare @PrintValue nvarchar(max)
select @xmlDoc=DESCRIPTION from dbo.WF_PERSIST_DESCRIPTOR where [PROCESS_ID]='1e9e9059-50ea-adac-4660-918cd54e3436' --将数据中的数据读取出来,数据库里面报错的是nvarchar(max)这里可以直接转换
set @xmlDoc.modify('replace value of (/Process/Activities/Activity[@key="N8"]/Name/text())[1] with "国美在线COO"') --替换掉某个节点下面的value值。 text() 是读取节点存储的text值
update dbo.WF_PERSIST_DESCRIPTOR set DESCRIPTION=Convert(nvarchar(max),@xmldoc) where [PROCESS_ID]='1e9e9059-50ea-adac-4660-918cd54e3436'
set @PrintValue=@xmlDoc.value('(/Process/Activities/Activity[@key="N8"]/Name)[1]','nvarchar(MAX)')
print @PrintValue