Query to search for a substring in xml

  • I use below query to search for a substring in whole xml(including node name and node value)

    SELECT *

    FROM tablename

    WHERE ( Charindex('abc',CAST([xmlcolumn] AS VARCHAR(MAX)))>0 )

    I want an alternative query which has good performance than this. So please suggest some.

  • So you want to return the whole xml document in the row, if it contains the string anywhere in it, be it an element name, element value, element attribute etc?

    If you can provide some samples of your xml, the table DDL, and the expected output, might be able to have a look at it in more detail.

    Follow me on twitter @EvoDBACheck out my blog Natural Selection DBA[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply