SQL Server UPPER Function

Summary: in this tutorial, you will learn how to use the SQL Server UPPER() function to convert a string to uppercase.

The UPPER() function converts an input string into uppercase. The following shows the syntax of the UPPER() function:

UPPER(input_string)
Code language: SQL (Structured Query Language) (sql)

In this syntax, the input_string can be a literal character string, variable, character string expression, or table column.

The type of the input_string must be implicitly convertible to VARCHAR. Otherwise, you must use the CAST() function to convert the input_string explicitly.

The UPPER() function returns the uppercase form of the input_string.

SQL Server UPPER() function examples #

Let’s take some examples of using the UPPER() function.

A) Using the UPPER() function with literal strings #

This example uses the UPPER() function to convert the string 'sql' to 'SQL':

SELECT 
    UPPER('sql') result;
Code language: SQL (Structured Query Language) (sql)

Here is the output:

result
------
SQL

(1 row affected)

B) Using the UPPER() function with table column #

We will use the production.products table from the sample database in this example:

products

The following statement uses the UPPER() function to convert product names uppercase:

SELECT 
    product_name, 
    UPPER(product_name) product_name_upper
FROM 
    production.products
ORDER BY 
    product_name;
Code language: SQL (Structured Query Language) (sql)

The following picture shows the partial output:

SQL Server UPPER Function example

In this tutorial, you have learned how to use the SQL Server UPPER() function to convert a string to uppercase.

Was this tutorial helpful?