I have a column that is of type xml. The xml looks like
...
<Person>
<Name>
<Address>
<City>
<State>
<zip>
<Primary>TRUE
</Name>
<Name>
....
</Name>
</Person>
I want to return the firstname and lastname where the primary equals true. But i don't know which person will have that set to true.. How can i do that?
I currently have:
but this will only return the first address.. How do i make it variable?
...
<Person>
<Name>
<Address>
<City>
<State>
<zip>
<Primary>TRUE
</Name>
<Name>
....
</Name>
</Person>
I want to return the firstname and lastname where the primary equals true. But i don't know which person will have that set to true.. How can i do that?
I currently have:
Code:
Select PersonXMl.Value('(/Person/Name/Address/)[1]', 'varchar(50)') as address
from tblName
where PersonXMl.Value('(/Person/Name/Address/city/state/zip/primary') = 'TRUE'
but this will only return the first address.. How do i make it variable?