Wednesday, March 21, 2012

how to tell the difference between upper and lower case?

Anyway to tell the difference BETWEEN uppercase and lowercase in SQL?
say youve two entries in a table that you wish to treat as different words?
"hello world"
and
"HELLO WORLD"
how would i construct a select statement that takes only the lowercase words??Select *
from table
where column = LOWER('VALUE');|||great,
that works
but now, how do you tell the difference between

"Dpi"

and

"dpi"

and

"dPI"

?|||Correct my If I'm wrong, but its seems like you are using MS SQL Server and your database is created with case-insensitive sort order.
(in most cases people have the opposite problem - how to treat mixed case as identical during search :).

You can re-create DB and use case-sensitive sort order. Also if i'm not mistaken SQL Server 2000 allows collation sequence on per column basis.|||Yes im using MS SQL Server 2000

Im gonna create a DB thats case sensitive and test that.

You can re-create DB and use case-sensitive sort order. Also if i'm not mistaken SQL Server 2000 allows collation sequence on per column basis.

whats this colation thingy!?!
im trying the help files, but it seems fairly complicated.|||Originally posted by MaxJam
great,
that works
but now, how do you tell the difference between

"Dpi"

and

"dpi"

and

"dPI"

?

--for Dpi
select * from table where column = initcap('dpi')
--for dpi
select * from table where column = lower('dpi')
--for dPI
select * from table where column != lower('dpi') and column != upper('dpi') and column != initcap('dpi') and lower(column) = lover('dpi')
--for DPI
select * from table where column = upper('dpi')

etc
etc

No comments:

Post a Comment