XML : SqlServer xml xpath count by node text

How do i count in SqlServer Xml a Text value for example. I want this query to return 1.

SELECT ISNULL(XML.value('count(/test/item/id/text()="2")','INT'), 0) as COUNT FROM MY TABLE

  <test>      <item>          <id>1</id>      </item>      <item>          <id>2</id>      </item>  </test>    

No comments:

Post a Comment