我正在尝试为包含逗号的所有ContentNode
节点查询以下XML。
<Node xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.xxx.xxx.xxx">
<SubNode>
<SubSubNode>
<ContentNode>Data, </ContentNode>
以下返回0结果:
select *
from Table
where [XML].exist('/Node/SubNode/SubSubNode [contains(ContentNode[1],",")]')=1
任何帮助都将不胜感激。
答案 0 :(得分:1)
您有一个默认命名空间,您需要在查询中使用它 看看WITH XMLNAMESPACES (Transact-SQL)
with xmlnamespaces(default 'http://schemas.xxx.xxx.xxx')
select *
from Table
where [XML].exist('/Node/SubNode/SubSubNode [contains(ContentNode[1],",")]')=1