gpt4 book ai didi

SQL 服务器 : Find records where XML is missing tag

转载 作者:数据小太阳 更新时间:2023-10-29 03:00:39 27 4
gpt4 key购买 nike

我有一个名为:XMLIndex 的表,其中包含一个名为:XMLRec 的列,该列包含 XML 文件的结构和值。

其中一些记录缺少名为:<ISO></ISO> 的标签

我的问题是:我需要运行什么类型的查询才能找到表 XMLIndex 中缺少 <ISO> 的所有记录标签?

这是一个包含 ISO 标记的 XMLRecord XML 示例:

<XMLRecord>
<pn>0042761</pn>
<SRI>4.40</SRI>
<igm>/images/images/0042761.gif</img>
<ISO>ZW</ISO>
<ListPrice>$5.50</ListPrice>
</XMLRecord>

还有一个有多个 ISO(看标签的细微差别):

<XMLRecord>
<pn>0042762</pn>
<SRI>4.40</SRI>
<igm>/images/images/0042762.gif</img>
<ISOs>ZW+NZ+AU+BR</ISOs>
<ListPrice>$5.50</ListPrice>
</XMLRecord>

缺少 ISO 标记的记录是 XML 结构不包含此类标记的记录。

非常感谢任何示例。

谢谢。

最佳答案

您可以使用 XQuery exist方法。

检查xml文档中的任何地方:

select *
from XMLIndex
where XMLRec.exist('//ISO') = 0

检查特定位置:

where XMLRec.exist('/XMLRecord/ISO') = 0

关于SQL 服务器 : Find records where XML is missing tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42307182/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com