2012-08-23 45 views
2

我正在嘗試查詢包含逗號的所有ContentNode節點的以下XML。Xquery SQL包含

<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

**什麼數據庫系統**,和哪個版本? * SQL *只是*結構化查詢語言* - 許多數據庫系統使用的語言,但不是數據庫產品... XML支持等特性非常特定於供應商 - 所以我們真的需要知道什麼**數據庫系統* *你正在使用.... –

回答

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