Searching a TEXT Column

  • I'd like to search for a string within a text (binary) column. Some searches seem to fail, and I cannot find a workaround.

    The basic query I am trying to run is:

    SELECT num

    FROM Press_Releases

    WHERE abstract LIKE '%5493%'

    ... hoping to get the number of the press release that contains the fragment of a phone number in the ABSTRACT column. The phone number is quite a ways down in the column, though, and I get no rows returned from this query. If I ask for a chunk of text that appears in the first paragraph of data, I can find it.

    I tried using PATINDEX:

    SELECT patindex('%5493%', abstract) PatternIndex

    , substring (abstract, patindex('%5493%', abstract) - 20, 40) SurroundText

    , NUM

    FROM Press_Releases

    WHERE patindex('%5493%', abstract) <> 0

    ... hoping that I'd find the text (and some surrounding text for orientation) along with the article number, but no joy.

    The text column 'abstract' contains more than 8000 characters.

    What should I try?

  • Full text searching is made for this. Not very hard to get set up, Jon Winer has a couple articles posted about using it you might find interesting.

    Andy

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

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