views:

3507

answers:

3

How do you make a field in a sql select statement all upper or lower case?

Example:

select firstname from Person

How do I make firstname always return upper case and likewise always return lower case?

+4  A: 

LCASE or UCASE respectively.

Example:

SELECT UCASE(MyColumn) AS Upper, LCASE(MyColumn) AS Lower
FROM MyTable
Stephen Wrighton
Is this for mysql?
Joshua Hudson
UCASE for lower and LCase for Upper?
Joshua Hudson
Stephen Wrighton
Thank you. I gave you a up vote because you are right about ISO SQL vs an implementation.
Joshua Hudson
+1  A: 

SQL SERVER 2005:

print upper('hello');
print lower('HELLO');
Cirieno
Perfect. Thank you Cirieno! I actually had this answer but wanted it to be documented on stack overflow since I only use this rarely I always forget it. :)
Joshua Hudson
+4  A: 
SELECT UPPER(firstname) FROM Person

SELECT LOWER(firstname) FROM Person
Jared
I'm giving Jared the answer since this is closer to my asked question.
Joshua Hudson