MSDN Documentation

UPPER (Transact-SQL)

On This Page

Description

Returns the given character string with all characters converted to uppercase. This function is case-insensitive, meaning it works the same regardless of the original casing of the input string.

Syntax

UPPER ( character_expression )

Arguments

character_expression
Is a character string of any valid SQL Server data type for character strings.

Return Value

Returns a character string of the same data type as the input, with all characters converted to uppercase. If the input is NULL, UPPER returns NULL.

Permissions

No specific permissions are required to use the UPPER function. It can be executed by any user.

Example Usage

Convert a string to uppercase:

SELECT UPPER('This is a test string.');

Result:

This Is A Test String.

Examples

Example 1: Basic Usage

The following statement returns the string 'HELLO WORLD':

SELECT UPPER('hello world');

Example 2: Using with Table Data

This example selects the ProductName column from the Production.Product table and converts all product names to uppercase.

SELECT
    ProductID,
    Name AS OriginalName,
    UPPER(Name) AS UppercaseName
FROM
    Production.Product
WHERE
    ProductID < 10;

Sample Result (for ProductID 1):

ProductID | OriginalName | UppercaseName
----------|--------------|--------------
1         | Adjustible   | ADJUSTIBLE

Example 3: Handling NULL Values

Demonstrates how UPPER handles NULL input:

SELECT
    CASE WHEN @myVar IS NULL THEN 'NULL Input' ELSE UPPER(@myVar) END AS Result;

If @myVar is NULL, the result will be 'NULL Input'. If @myVar is 'Test', the result will be 'TEST'.

See Also