SQL 2005 XML Searching

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%")
zzzxtreme [ Mi, 16 April 2008 07:11 ] [ ID #1943680 ]

Re: SQL 2005 XML Searching

Here is one way:

SELECT keycol, datacol
FROM Foo
WHERE datacol.exist('/details/attribute[ [at] id = "2"]') = 1
AND datacol.exist('/details/attribute[substring( [at] value, 1, 1) = "y"]') =
1;

HTH,

Plamen Ratchev
http://www.SQLStudio.com
Plamen Ratchev [ Mi, 16 April 2008 16:28 ] [ ID #1943687 ]
Datenbanken » comp.databases.ms-sqlserver » SQL 2005 XML Searching

Vorheriges Thema: difference between explicit inner join and implicit
Nächstes Thema: Query Japanese Text in an NVarChar?