SQL UPPER Function (Transact SQL)

·

·

The SQL UPPER function converts the input character expression to an upper case and returns it.

Description

The UPPER function reads the input expression and converts lowercase characters to uppercase.

SQL UPPER Function Usage Notes

The character expression is the only argument for the UPPER function. It is the text to be converted to an upper case. The data type can be a character or a binary. The data type should be implicitly convertible to the varchar data type. Otherwise, the CAST function explicitly converts the character expression to varchar.

The input character data can be a constant, a variable, or a column value.

In the case of the NULL argument, the result is a NULL expression. The upper case character data in the input expression remains unchanged.

The return data type is varchar or nvarchar.

Syntax

UPPER (input_character_expression)

SQL UPPER Examples

The following examples show the use of the UPPER function for string manipulation in SQL.

SELECT UPPER('convert to upper case');
/* Answer */
SELECT UPPER('convert to upper case');

Here is the same showing a mixed case example:

SELECT UPPER('cONVERT tO uPPER cASE') MixedToUpper;
/* Answer */
SELECT UPPER('cONVERT tO uPPER cASE') MixedToUpper;

The following example uses AdventureWorks2019 database.

SELECT UPPER(Title) + ' ' + UPPER(FirstName) + ' ' + UPPER(LastName) FullName FROM Person.Person
/* Answer */
SELECT UPPER(Title) + ' ' + UPPER(FirstName) + ' ' + UPPER(LastName)  FullName 
FROM Person.Person

The query selects and displays the complete name of each person in the upper case.

See Also

More from the blog


MySQL PostgreSQL SQLite SqlServer