This is a discussion on SQL 2005 XML Searching within the SQL Server forums, part of the Microsoft SQL Server category; --> hi i have a table with an XML column this XML data looks like this <details><attribute id="1" value="x"/><attribute id="2" ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| hi i have a table with an XML column this XML data looks like this <details><attribute id="1" value="x"/><attribute id="2" value="y"/ ><attribute id="3" value="z"/></details> could anyone help guide me on how to search something like this? ------- Select * from Table Where (XMLColumn contains attribute of id="2" and value like "y%") |
| ||||
| Here is one way: SELECT keycol, datacol FROM Foo WHERE datacol.exist('/details/attribute[@id = "2"]') = 1 AND datacol.exist('/details/attribute[substring(@value, 1, 1) = "y"]') = 1; HTH, Plamen Ratchev http://www.SQLStudio.com |
| Thread Tools | |
| Display Modes | |
|
|