Finding Duplicate in XML Attribute



In my SQL Server DB,I have table with XML Attribute. The XML that goes in it is like the sample below:



<Rows>
<Row>
<Name>John</Name>
</Row>
<Row>
<Name>Debbie</Name>
</Row>
<Row>
<Name>Annie</Name>
</Row>
<Row>
<Name>John</Name>
</Row>
</Rows>


I have a requirement that i need to find the occurrence of all rows where the XML data has duplicate entries of Name. For ex. above we have 'John' twice in the xml. I can use the exist xml statement to find 1 occurrence, but how can i find if its more than 1.


Thanks.


No comments:

Post a Comment