日期:2014-05-17  浏览次数:20454 次

请教一个XML查询的例子
建了一个表有xml列
然后用

insert into  RecordLabelXML (xmlRecordLabel)
select * from openrowset (
bulk 'D:\数据库作业\sd.txt ',single_blob) as x;


一个xml文档 就插入这列,但是也就是一行

然后我 
select xmlRecordLabel.query('/root/RecrodLabel/') as result
from RecordLabelXML


可以查询出来, 如果我想加条件查询 就不行 

select xmlRecordLabel.query('/root/RecrodLabel/') as result
from RecordLabelXML
where  xmlRecordLabel.exist('/root/RecrodLabel/recordlabelid/') =5


我就是想把 <recordlabelid> =2 的整个node找出来,请问怎么做到?

我的xml文档 
<root>
    <RecrodLabel>
        <recordlabelid>0</recordlabelid>
        <name>Stanton</name>
        <addressid>Lesotho</addressid>
    </RecrodLabel>
    <RecrodLabel>
        <recordlabelid>1</recordlabelid>
        <name>Easthampton</name>
        <addressid>Sweden</addressid>
    </RecrodLabel>
    <RecrodLabel>
        <recordlabelid>2</recordlabelid>
        <name>Mesquite</name>
        <addressid>Bahamas</addressid>
    </RecrodLabel>
    <RecrodLabel>
        <recordlabelid>3</recordlabelid>
        <name>Niagara Falls</name>
        <addressid>Brazil</addressid>
    </RecrodLabel>
    <RecrodLabel>
        <recordlabelid>4</recordlabelid>
        <name>Brunswick</name>
        <addressid>Djibouti</addressid>
    </RecrodLabel>
    <RecrodLabel>
        <recordlabelid>5</recordlabelid>
        <name>Fort Smith</name>
        <addressid>Guadeloupe</addressid>
    </RecrodLabel>
</root>