Get names which starts with small letters;

  • If my Table name "Employee" and field name is "FirstName"

    Suppose I have names like"

    Abc

    abc

    ali

    Ali

    shaik

    shAik

    In these names I want only those names which are having small 'a' character;

  • I believe you will need to add COLLATE to your select statment with a case sensitive character set.

  • Obviously, insert your case sensitive character set as appropriate

    select [COLUMN]

    from dbo.

    WHERE [COLUMN] like 'a%' COLLATE Latin1_General_CS_AS

  • Or you can use ASCII function to separate upper from lower case letters

  • I've used ASCII comparisons for that kind of thing many times.

    select *

    from dbo.MyTable

    where ASCII(MyColumn) between 97 and 122;

    The ASCII function returns the ASCII value of the left character in a string.

    Edit: Change it to "=97" instead of the between check, if you just want ones starting with "a" instead of "A".

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • select [COLUMN]

    from dbo.

    WHERE [COLUMN] not like '%[A-Z]%' COLLATE Latin1_General_BIN

  • alishaik001 (12/21/2011)


    If my Table name "Employee" and field name is "FirstName"

    Suppose I have names like"

    Abc

    abc

    ali

    Ali

    shaik

    shAik

    In these names I want only those names which are having small 'a' character;

    Are you looking for names that have a small "a" anywhere in the name? If you are, something like this:

    SELECT FirstName

    FROM Employee

    WHERE FirstName LIKE '%a%' COLLATE Latin1_General_BIN

    John

Viewing 7 posts - 1 through 6 (of 6 total)

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