Case sensitive search

  • How can I do a case sensitive search? I only want to return results that match 'DEFAULT' not all that have 'Default'

    WHERE     (fac = 'DEFAULT')

  • Try the link below to get started.  Hope this helps.

    http://vyaskn.tripod.com/case_sensitive_search_in_sql_server.htm

    Kind regards,

    Gift Peddie

    Kind regards,
    Gift Peddie

  • hi,

    if your server is case-sensitive then your where clause will only find rows that match "DEFAULT". If your server is case-insensitive then use one of the solutions from the document.

    hope this helps

    Paul

  • hey thatz quite simple...

    just follow this way...

    where upper(fac) = upper(watever here)

    or

    where lower(fac) = lower(watever here)

  • hey thatz quite simple...

    just follow this way...

    where upper(fac) = upper(watever here)

    or

    where lower(fac) = lower(watever here)

  • Have you actually tested this solution Riyaz???

  • Riyaz,

    By doing what you've described, a case INSENSITVE search will result.  The following results in a match even though they are different cases.

    declare @fac varchar(20)

            ,@fac2 varchar(20)

           

    select @fac = 'Abc'

          ,@fac2 = 'aBC'      

    select 'match'

    where UPPER(@fac) = UPPER(@fac2)

  • Try without the upper.

    See any difference??

  • I do on a server with a case sensitive collation setting. 

    My point was that no matter what collation is selected, the query will result in a match when using UPPER() or LOWER() and that Riyaz' advice will never work.  In order to do a case sensitive match one of the options previously mentioned should be used if the collation setting is insensitive.

  • hey mate...wat i had posted will do a perfect insensitive search...

    but will affect urs...

    sorry should have read ur description clearly...

    i ve now read...but again the solution is simple

    try this...

     where cast(fac as binary) = cast('DEFAULT' as binary)

Viewing 10 posts - 1 through 9 (of 9 total)

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