Like Statement

  • Is there anyway in which I can use the like statement to search for a whole word with spaces before and after?

    i.e. I am currently using the following

    WHERE description LIKE '%arco%'

    but this brings out lines with charcoal in them.  What I would like to look for it where arco appears on it own so

    WHERE description LIKE '% arco %'

    but this doesn't work.

    Can anyone help?

    Regards

    Carly

  • you can do something like this

    where Description LIKE '% arco%' or Description LIKE '%arco %'

    HTH

    Meghana


    Regards,

    Meghana

  • use tempdb

    create table #test

    (

     c1 varchar(10)

    )

    insert into #test values('charcoal')

    insert into #test values('c arco l')

    select * from #test where c1 like '%[ ]arco[ ]%'

    drop table #test

    c1        

    ----------

    c arco l

    (1 row(s) affected)

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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