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:

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