1

parentProblem 要素の直接の子ではない、空の組織要素を見つけたいと思います。

そのようです..

select * from Audit.PatientAudit pa
where pa.BeforeXml.exist('//*:organisation[not(../*:parentProblem)]') = 1

しかし、それはうまくいかないようです、何かアイデアはありますか?

4

1 に答える 1

2
declare @T table(BeforeXml xml)

insert into @T values
('<root>
    <parentProblem>
      <organisation/>
    </parentProblem>
  </root>'), 
('<root>
    <anotherProblem>
      <organisation/>
    </anotherProblem>
  </root>'),
('<root>
    <anotherProblem>
      <organisation ID="1"/>
    </anotherProblem>
  </root>') 

select *
from @T pa
where pa.BeforeXml.exist('//organisation[local-name(..)!="parentProblem" and count(@*)=0]') = 1
于 2011-05-25T21:10:16.637 に答える