SQL changing a value to upper or lower case

SqlCaseUppercaseLowercase

Sql Problem Overview


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?

Sql Solutions


Solution 1 - Sql

SELECT UPPER(firstname) FROM Person

SELECT LOWER(firstname) FROM Person

Solution 2 - Sql

LCASE or UCASE respectively.

Example:

SELECT UCASE(MyColumn) AS Upper, LCASE(MyColumn) AS Lower
FROM MyTable

Solution 3 - Sql

SQL SERVER 2005:

print upper('hello');
print lower('HELLO');

Solution 4 - Sql

You can use LOWER function and UPPER function. Like

SELECT LOWER('THIS IS TEST STRING')

Result:

this is test string

And

SELECT UPPER('this is test string')

result:

THIS IS TEST STRING

Solution 5 - Sql

You can do:

SELECT lower(FIRST NAME) ABC
FROM PERSON

NOTE: ABC is used if you want to change the name of the column

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoshua HudsonView Question on Stackoverflow
Solution 1 - SqlJaredView Answer on Stackoverflow
Solution 2 - SqlStephen WrightonView Answer on Stackoverflow
Solution 3 - SqlCirienoView Answer on Stackoverflow
Solution 4 - SqlMuhammad AwaisView Answer on Stackoverflow
Solution 5 - SqlXyed Xain HaiderView Answer on Stackoverflow