Back to Library

UPPER() in SQL

Converts all characters in a string to uppercase letters.

Syntax

UPPER(string)
Return type
VARCHAR (or equivalent string type in the respective DBMS)

UPPER() Function Example

SELECT UPPER('Hello World');
-- Output: 'HELLO WORLD'

What is UPPER() in SQL?

The UPPER() function in SQL is used to convert all characters in a given string to uppercase. This function is particularly useful when performing case-insensitive comparisons, standardizing text formatting, or ensuring uniformity in stored data. It is supported in various database systems, including MySQL, PostgreSQL, SQL Server, and SQLite. The UPPER() function does not modify the original data but returns a new string with all letters capitalized. It is commonly used in SELECT queries to format output dynamically or match case-sensitive values consistently across datasets.

Parameters:

string: The input string or column to be converted to uppercase

Example Use Cases:

-- Standardize company names

SELECT UPPER(company_name) AS normalized_name FROM companies;
-- Output:
company_name        normalized_name
----------------    ----------------
Tech Corp           TECH CORP
acme Inc            ACME INC
Global Systems      GLOBAL SYSTEMS
micro soft          MICRO SOFT
Apple inc           APPLE INC

-- Case-insensitive search

SELECT * FROM users WHERE UPPER(email) = UPPER('John.Doe@EXAMPLE.com');
-- Output:
id    email                    matches
----  ----------------------   --------
1     john.doe@example.com2     John.Doe@Example.com    
3     JOHN.DOE@EXAMPLE.COM    
4     john.doe@Example.com    
5     JoHn.DoE@eXaMpLe.CoM    

-- Consistent display format

SELECT UPPER(product_code) AS product_identifier FROM products;
-- Output:
product_code    product_identifier
------------    ------------------
prod-a101       PROD-A101
Prod-B202       PROD-B202
PROD-C303       PROD-C303
prod-D404       PROD-D404
Prod-e505       PROD-E505


Notes:

  • Behavior: Converts all alphabetic characters to uppercase; numbers and special characters remain unchanged

  • Performance Considerations: Minimal impact on performance, suitable for large-scale operations

  • Version Info: Core SQL function, available in all major DBMS versions

Error Handling:

  • Error: Generally doesn't throw errors, returns NULL for NULL input

Supported Databases:

DBMS
Function / Syntax
Example
Behavior with NULL
MySQL

UPPER()

UPPER('hello')

Returns NULL

PostgreSQL

UPPER()

UPPER('hello')

Returns NULL

SQL Server

UPPER()

UPPER('hello')

Returns NULL

SQLite

UPPER()

UPPER('hello')

Returns NULL

BigQuery

UPPER()

UPPER('hello')

Returns NULL

Snowflake

UPPER()

UPPER('hello')

Returns NULL

Athena

UPPER()

UPPER('hello')

Returns NULL

Related Functions:

REVERSE()

Returns a string value in a reversed order (characters displayed in reverse order).

Returns a string value in a reversed order (characters displayed in reverse order).

Returns a string value in a reversed order (characters displayed in reverse order).

Returns a string value in a reversed order (characters displayed in reverse order).

STUFF()

Deletes a specified length of characters and inserts another string at a specified start position in a string.

Deletes a specified length of characters and inserts another string at a specified start position in a string.

Deletes a specified length of characters and inserts another string at a specified start position in a string.

Deletes a specified length of characters and inserts another string at a specified start position in a string.

PATINDEX()

Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.

Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.

Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.

Returns the starting position of the first occurrence of a pattern in a string. Uses pattern matching with wildcards.

RIGHT()

Extracts a specified number of characters from the end (right side) of a string.

Extracts a specified number of characters from the end (right side) of a string.

Extracts a specified number of characters from the end (right side) of a string.

Extracts a specified number of characters from the end (right side) of a string.

CHARINDEX()

Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).

Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).

Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).

Returns the starting position of a substring within a string. Position is 1-based (first character is position 1).

LEFT()

Extracts a specified number of characters from the beginning (left side) of a string.

Extracts a specified number of characters from the beginning (left side) of a string.

Extracts a specified number of characters from the beginning (left side) of a string.

Extracts a specified number of characters from the beginning (left side) of a string.

REPLACE()

Replaces all occurrences of a substring within a string with another substring.

Replaces all occurrences of a substring within a string with another substring.

Replaces all occurrences of a substring within a string with another substring.

Replaces all occurrences of a substring within a string with another substring.

LENGTH()/LEN()

Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).

Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).

Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).

Returns the number of characters in a string. Note: Function name varies by DBMS (LENGTH in most, LEN in SQL Server).

SUBSTRING()

Extracts a portion of a string based on specified position and length.

Extracts a portion of a string based on specified position and length.

Extracts a portion of a string based on specified position and length.

Extracts a portion of a string based on specified position and length.

UPPER()

Converts all characters in a string to uppercase letters.

Converts all characters in a string to uppercase letters.

Converts all characters in a string to uppercase letters.

Converts all characters in a string to uppercase letters.

CONCAT()

Concatenates two or more strings into a single string.

Concatenates two or more strings into a single string.

Concatenates two or more strings into a single string.

Concatenates two or more strings into a single string.

One place for all your queries,
directly on your SQL editor