Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Query Help

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
0
0
US
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:
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?
 
[link MSDN][/url] should help you. In particular, check out section C in the link.

------------------------------------------------------------------------------------------------------------------------
Reason and free inquiry are the only effectual agents against error; they are the natural enemies of error and of error only.

Thomas Jefferson

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top