我需要在群ID字段更新为0。我已经找到了如何检索值,我现在遇到了问题更新它。
任何帮助将GE太棒了!
<ProblemProfile>
<GroupID>-1</GroupID>
<LayoutID>1</LayoutID>
<MyQueries>false</MyQueries>
</ProblemProfile>
Declare @Result xml
set @Result = convert(xml,(select ProfileXML from profiles where id = 23))
SELECT x.value('.', 'int') ID
FROM @Result.nodes('/ProblemProfile/GroupID') as R(x)
更新
我现在要做的就是更新每一行的群ID有“富”的价值
declare @foo int
set @foo = -1
UPDATE profiles
SET ProfileXML.modify('replace value of (/ProblemProfile/GroupID/text())[1] with "0"')
WHERE ProfileXML.value('(/ProblemProfile/GroupID)[1]', 'int') = @foo
这是唯一的更新满足此条件的第一行。 我如何将更新的每一行?
更新2该声明的作品。 原来为第一个节点的数据库结构可以是不同的。 一个简单的//GroupID...etc更新的每一行。 它始终是绊倒我们哈哈愚蠢的小事情。