Get XML node values(SQL Server 2005)
Hello,
I have a XML column containing data like
few rows of the table
<Books>
<Authors><ID>10</ID><ID>20</ID><ID>30</ID><ID>40</ID>
<Authors>
</Books>
<Books>
<Authors><ID>10</ID><ID>20</ID><ID>30</ID>
<Authors>
</Books>
<Books>
<Authors><ID>10</ID><ID>40</ID>
<Authors>
</Books>
<Books>
<Authors><ID>20</ID><ID>40</ID>
<Authors>
</Books>
I would like to fetch the value 40 if and only if 10 is present in the XML column. but I should not pick up the value 20 or 30.
I dont know how many <ID></ID> nodes will be there in the data some times 1, 2, 3 or 4.
In the above case only 1st and 3rd row should give value 40.
Thanks in advance
|