LIKE keyword - is it case sensitive or not ?

  • I user like keyword in my query. I got result with that query which is not case sensitive.

    Ex. if I use   like'%test%' in this way then it return result "TEST","test", "Test".

    Is like keyword is not case sensitive in sql server 2000.

    Thanks in advance..

  • The case-sensitivity is not related to operators in SQL Server. It depends on whether you have case-sensitive collation defined for your database/table. You can force case-sensitivity in your like statement by using binary collation though as follows:

     

    -- Prepare sample data

    declare @t table

    (

     a varchar(50)

    )

    insert @t

    select 'test' union all select 'Test' union all select 'TEST'

    -- final query

    select * from @t where a collate Latin1_General_BIN like 'TEST'

  • case sensitivity depends on the server/database collation and it does not affect sql operators, statements and internal commands directly. it depends on your database and/or the server.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

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

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