Search XML with a LIKE or similar full search operation Search XML with a LIKE or similar full search operation xml xml

Search XML with a LIKE or similar full search operation


The simplest (but definitely not the fastest to execute) way would be to cast your column to nvarchar(max) before passing it to like:

cast(ValueXml as nvarchar(max)) like '%PreviewDateRange%'


There you go:

SELECT *FROM MyTableWHERE MyXmlMetadataColumn.exist('//*/text()[contains(upper-case(.),upper-case("MySearchTerm"))]') = 1

This seems to work fine for me and also does not search the XML tag names as the solution provided by "dasblinkenlight".

I don't know how performant it is though.