FInding results when looking for spaces

  • I am searching a table looking for instances of a field being broken with spaces.

    eg. select blar blar from blar blar where textvalue like '% \f %'

    (note the spaces between the %)

    I know there are results matching this criteria, but the query comes back blank !

     

    Can anyone help ???

  • Paul,

    You could try using CHARINDEX (take a look in BOL) like this:

    SELECT myCol FROM myTable WHERE CHARINDEX( ' ', myCol, 1 ) > 0

    There is a space in between the apostrophes, honest!!



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • Can you show us some data that does contain that string?  For my little test, it does work.

    DECLARE @WordSearch TABLE( Word varchar(100))

    INSERT INTO @WordSearch

    SELECT 'This string has \f in it'

    UNION ALL

    SELECT 'This string has |\f in it'

    UNION ALL

    SELECT 'This string does not have the text searched for in it'

    SELECT * FROM @WordSearch WHERE Word LIKE '% \f %'

     

    I wasn't born stupid - I had to study.

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

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