views:

48

answers:

1

Let's say I have a column in a table where the datatype is XML. I have a specific value I want query for in an xml tag that is unique(no repeating) in the XML. How do I do this?

Something like:

select * from MyTable 
 where XMLColumn.TagImLookingAt.Value = @QueryValue
+4  A: 

Use:

WHERE xmlcolumn.value('(/path/to/tag)[1]', 'int') = @QueryValue

Change the data type to whatever is appropriate.

For more info, see the documentation - specifically the methods available when dealing with the XML data type...

OMG Ponies
+1 Faster than me.
Joe Stefanelli