[sql] SQL changing a value to upper or lower case

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?

This question is related to sql case uppercase lowercase

The answer is


LCASE or UCASE respectively.

Example:

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

You can do:

SELECT lower(FIRST NAME) ABC
FROM PERSON

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


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

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

You can do:

SELECT lower(FIRST NAME) ABC
FROM PERSON

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


LCASE or UCASE respectively.

Example:

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

LCASE or UCASE respectively.

Example:

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

SQL SERVER 2005:

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

LCASE or UCASE respectively.

Example:

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

SQL SERVER 2005:

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

Examples related to sql

Passing multiple values for same variable in stored procedure SQL permissions for roles Generic XSLT Search and Replace template Access And/Or exclusions Pyspark: Filter dataframe based on multiple conditions Subtracting 1 day from a timestamp date PYODBC--Data source name not found and no default driver specified select rows in sql with latest date for each ID repeated multiple times ALTER TABLE DROP COLUMN failed because one or more objects access this column Create Local SQL Server database

Examples related to case

PostgreSQL CASE ... END with multiple conditions SQL Server: use CASE with LIKE SQL Server IIF vs CASE SELECT using 'CASE' in SQL SELECT query with CASE condition and SUM() GROUP BY + CASE statement SQL use CASE statement in WHERE IN clause SQL Server - Case Statement where to place CASE WHEN column IS NULL in this query Regarding Java switch statements - using return and omitting breaks in each case

Examples related to uppercase

Capitalize the first letter of string in AngularJs Ignoring upper case and lower case in Java Convert from lowercase to uppercase all values in all character variables in dataframe In Android EditText, how to force writing uppercase? how to convert Lower case letters to upper case letters & and upper case letters to lower case letters How to convert a string from uppercase to lowercase in Bash? How to change a string into uppercase Java Program to test if a character is uppercase/lowercase/number/vowel How do I lowercase a string in Python? Capitalize or change case of an NSString in Objective-C

Examples related to lowercase

Ignoring upper case and lower case in Java how to convert Lower case letters to upper case letters & and upper case letters to lower case letters How to detect lowercase letters in Python? .toLowerCase not working, replacement function? How to convert a string from uppercase to lowercase in Bash? How to convert array values to lowercase in PHP? Java Program to test if a character is uppercase/lowercase/number/vowel How do I lowercase a string in Python? How do I lowercase a string in C? How to convert a string to lower case in Bash?