2

I have a table with person's information. I need to extract all person's who have their FirstName column's first character starting with lowercase.

-- Persons
Mike
Peter
andrew
jason
Elena

-- Output
andrew
jason

Thanx in advance. Any suggestion would be helpful.

Murtaza Munshi
  • 1,065
  • 4
  • 13
  • 40
  • 1
    Further to nscheaffer's answer. There are many ways this can be done. Check out http://www.mytecbits.com/microsoft/sql-server/case-sensitive-search-fetching-lowercase-or-uppercase-string – Eric S May 26 '16 at 14:05

4 Answers4

2

Here you go...

select *
from PersonsTable
where ascii(left(Name, 1)) between 97 and 122
Isaac
  • 3,240
  • 2
  • 24
  • 31
1

Something like this, by checking the first character of the string.

SELECT DISTINCT p.FirstName 
FROM dbo.tblPersons p
WHERE LEFT(p..FirstName, 1) = LOWER(LEFT(p..FirstName, 1)) Collate SQL_Latin1_General_CP1_CS_AS
Naveen
  • 144
  • 5
0

I found it on this link

How to find rows that have a value that contains a lowercase letter

IN MS SQL server use the COLLATE clause as mentioned in this post:

http://blog.sqlauthority.com/2007/04/30/case-sensitive-sql-query-search/

Community
  • 1
  • 1
Murtaza Munshi
  • 1,065
  • 4
  • 13
  • 40
0

you can use IF test not in ( ABCDEF...) in your main programme :

list = { A,B ....

if(! list.contains(name.substring(1)){

}

Chakib Arrama
  • 93
  • 3
  • 12
  • 2
    Hi Chakib, welcome to Stackoverflow. Although answers are appreciated, this question is for MSSQL and not Java. – Eric S May 26 '16 at 14:06