The Wayback Machine - https://web.archive.org/web/20240930234011/https://www.geeksforgeeks.org/upper-function-in-sql/
Open In App

SQL UPPER() Function

Last Updated : 31 May, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The SQL UPPER() function is a string function that converts all the strings in the table to uppercase.

UPPER() Function in SQL

The UPPER function in SQL is an in-built function that changes lowercase characters or strings to capital cases. Certain characters like integers (0-9) or special characters like (“@”, “-” “/”, “&” etc.) remain unchanged in the result.

It is used to display the output in CAPITAL CASE and is supported by all major SQL-based DBMSs.

Note: UPPER and UCASE functions perform the same operation on strings. In older versions of SQL, some databases (like Db2 DBMS)used the UCASE function, while others used the UPPER function. Now both the functions are supported by all major databases.

The UPPER function is supported in SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse, MySQL 4.0, Oracle, DB2, and all other major Database systems.

Syntax

SQL UPPER function syntax is:

UPPER(input_text);

OR

UPPER(column_name);

SQL UPPER() Function Examples

Let’s look at the examples of UPPER() function in SQL. Check the SQL UPPER function with examples to understand it better.

First, let’s create a demo database and table on which we will use the UPPER function.

Demo SQL Database

We will be using the following table in the examples:

ID

NAME

12@tEsla

Elon

x

Musk

Microsoft

Bill

To create this table in your system, write the following queries:

MySQL
CREATE TABLE GFG_UPPER_DEMO(
    Id Varchar(20),
    Name varchar(20)
);
INSERT INTO GFG_UPPER_DEMO VALUES    
    ("12@tEsla", "Elon"),
    ("x" ,"Musk"), 
    ("Microsoft", "Bill") ; 

Convert Character Literal to Uppercase Using SQL Upper Function

In this example, we are printing the x value as it is in first column, and in the second column we are printing the ID value after applying the UPPER function, and the UPPER function converted “x” into “X”.

Query:

SELECT  "x" as  "BEFORE UPPER() Function" ,  UPPER("x")  as  "AFTER UPPER() Function";

Output:

converting character to uppercase

Converting Character Literal to Capital Case Using UPPER() function.

Convert string to Uppercase using SQL UPPER Function

IIn this example, in the first column, we are printing the “Microsoft” word as it is, and in the second column we are printing the “Microsoft” value after applying the UPPER() function, and the UPPER function converted “Microsoft” into “MICROSOFT“.

Query:

SELECT  "Microsoft"  as  "BEFORE UPPER() Function" ,  UPPER("Microsoft")  as  "AFTER UPPER() Function";

Output:

converting string literal to uppercase-Using-UPPER()-function

Converting Character Literal to Capital Case Using UPPER() function.

Using UPPER Function on String Consisting of Special Characters, Integers, and Alphabets

In this example, in the first column, we are printing the ID value as it is, and in the second column we are printing the ID value after applying the UPPER function, and “12@tEsla” is converted to “12@TESLA“. The special characters and Numerical characters remained the same, only the alphabets are converted into capital case.

SELECT  "12@tEsla"  as  "BEFORE UPPER() Function" ,  UPPER("12@tEsla")  as  "AFTER UPPER() Function" ;

Output:

using upper function on string consisting of special characters, integers, and alphabets

Converting a String with Numerical characters and Special Characters into Capital Case using UPPER() function.

Using SQL UPPER function on a Column

In this example, we passed a column name ID as an argument to the UPPER() function. It converts all the values present in the ID column and outputs. In the first column, we can see the ID values before using the UPPER() function. In the second column, We can see all the alphabetic characters get converted into Capital Cases. Integer and special characters remain as it is. As we can see, “x“, “Microsoft“, and “12@tEsla” are converted into “X“, “MICROSOFT“, and “12@TESLA” respectively.

Query:

SELECT  ID  as  "BEFORE UPPER() Function" ,  UPPER(ID)  as  "AFTER UPPER() Function"  FROM GFG_UPPER_DEMO;

Output:

using upper function on a column

Passing a column name to the UPPER() function and Converting it to Capital Case.

Important Points About SQL UPPER() Function

  • UPPER() function in SQL allows us to convert the string text into uppercase.
  • It takes only one parameter and converts the entire string into upper case.
  • It is similar to the UCASE() function.
  • Special Characters like “@”, “%”, “+” etc. and numerical characters remain unchanged, only the lowercase alphabetical letters get transformed into uppercase.

Previous Article
Next Article

Similar Reads

UPPER() function in SQL Server
The UPPER() function in SQL Server is a useful tool for converting all characters in a string to uppercase. This function is essential for ensuring uniform text formatting and for performing case-insensitive comparisons. In this article, We will learn about the UPPER() function in SQL Server by understanding various examples and so on. UPPER() func
3 min read
PLSQL | UPPER Function
The PLSQL UPPER function is used for converting all letters in the specified string to uppercase. If there are characters in the string that are not letters, they are unaffected by this function. The char to be converted can be any of the datatypes such as CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The value returned by the UPPER function is
2 min read
UCASE() or UPPER() Function in MySQL
1. UCASE() : This function could be used to convert a string to upper-case. This function is similar to the UPPER() function. UPPER()\UCASE() are built-in MySQL function. Syntax : SELECT UCASE(text) Example - SELECT UCASE("MySQL on geeksforgeeks is FUN!") AS UpperText; Output : UpperTextMYSQL ON GEEKSFORGEEKS IS FUN! Now, here you will see UPPER fu
1 min read
Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
Structured Query Language (SQL): Structured Query Language (SQL) has a specific design motive for defining, accessing and changement of data. It is considered as non-procedural, In that case the important elements and its results are first specified without taking care of the how they are computed. It is implemented over the database which is drive
2 min read
Configure SQL Jobs in SQL Server using T-SQL
In this article, we will learn how to configure SQL jobs in SQL Server using T-SQL. Also, we will discuss the parameters of SQL jobs in SQL Server using T-SQL in detail. Let's discuss it one by one. Introduction :SQL Server Agent is a component used for database task automation. For Example, If we need to perform index maintenance on Production ser
7 min read
SQL SERVER – Input and Output Parameter For Dynamic SQL
An Input Parameter can influence the subset of rows it returns from a select statement within it. A calling script can get the value of an output parameter. An aggregate function or any computational expression within the stored process can be used to determine the value of the output parameter. A parameter whose value is given into a stored proced
3 min read
Difference between T-SQL and PL-SQL
1. Transact SQL (T-SQL) : T-SQL is an abbreviation for Transact Structure Query Language. It is a product by Microsoft and is an extension of SQL Language which is used to interact with relational databases. It is considered to perform best with Microsoft SQL servers. T-SQL statements are used to perform the transactions to the databases. T-SQL has
3 min read
SQL Server | Convert tables in T-SQL into XML
In this, we will focus on how tables will be converted in T-SQL into XML in SQL server. And you will be able to understand how you can convert it with the help of command. Let's discuss it one by one. Overview :XML (Extensible Markup Language) is a markup language similar to HTML which was designed to share information between different platforms.
2 min read
SQL - SELECT from Multiple Tables with MS SQL Server
In SQL we can retrieve data from multiple tables also by using SELECT with multiple tables which actually results in CROSS JOIN of all the tables. The resulting table occurring from CROSS JOIN of two contains all the row combinations of the 2nd table which is a Cartesian product of tables. If we consider table1 contains m rows and table2 contains n
3 min read
How to Execute SQL Server Stored Procedure in SQL Developer?
A stored procedure is a set of (T-SQL ) statements needed in times when we are having the repetitive usage of the same query. When there is a need to use a large query multiple times we can create a stored procedure once and execute the same wherever needed instead of writing the whole query again. In this article let us see how to execute SQL Serv
2 min read
SQL Query to Check if Date is Greater Than Today in SQL
In this article, we will see the SQL query to check if DATE is greater than today's date by comparing date with today's date using the GETDATE() function. This function in SQL Server is used to return the present date and time of the database system in a ‘YYYY-MM-DD hh:mm: ss. mmm’ pattern. Features: This function is used to find the present date a
2 min read
SQL Query to Add a New Column After an Existing Column in SQL
Structured Query Language or SQL is a standard Database language that is used to create, maintain and retrieve data from relational databases like MySQL, Oracle, SQL Server, Postgres, etc. In Microsoft SQL Server, we can change the order of the columns and can add a new column by using ALTER command. ALTER TABLE is used to add, delete/drop or modif
3 min read
SQL Query to Convert Rows to Columns in SQL Server
In this article we will see, how to convert Rows to Column in SQL Server. In a table where many columns have the have same data for many entries in the table, it is advisable to convert the rows to column. This will help to reduce the table and make the table more readable. For example, Suppose we have a table given below: NAMECOLLEGEROLL NUMBERSUB
2 min read
Dynamic SQL in SQL Server
In SQL Server, at times the SQL Queries need to be dynamic and not static, meaning the complete SQL query may be built dynamically at run time as a string using the user inputs and any specific application logic. This can be done in queries run from back-end applications or inside stored procedures. In this article let us look into the details abou
6 min read
Dynamic SQL and Temporary Tables in SQL Server
In SQL Server, creating and using Temp Tables using dynamic SQL is a good feature when we need to temporarily create tables at run time and delete automatically all within a session. They can be very useful when we need to store temporary data in a structured format and do data manipulation using Data Manipulation Language in SQL. In this article l
6 min read
How to SQL Select from Stored Procedure using SQL Server?
There may be situations in SQL Server where you need to use a stored procedure to get data from a SQL query. For direct data selection from a stored procedure within a query, SQL Server offers options like OPENQUERY and OPENROWSET. The usual way is running the stored procedure independently and then querying the outcomes. The idea of utilizing SQL
3 min read
SQL Quiz : Practice SQL Questions Online
This SQL quiz covers various topics like SQL basics, CRUD operations, operators, aggregation functions, constraints, joins, indexes, transactions, and query-based scenarios. We've included multiple-choice questions, fill-in-the-blank questions, and interactive coding challenges to keep things interesting and challenging. Whether you're a beginner l
3 min read
BULK INSERT in SQL Server(T-SQL command)
BULK INSERT in SQL Server(T-SQL command): In this article, we will cover bulk insert data from csv file using the T-SQL command in the SQL server and the way it is more useful and more convenient to perform such kind of operations. Let's discuss it one by one.  ConditionSometimes there is a scenario when we have to perform bulk insert data from .cs
3 min read
SQL Exercises : SQL Practice with Solution for Beginners and Experienced
SQL (Structured Query Language) is a powerful tool used for managing and manipulating relational databases. Whether we are beginners or experienced professionals, practicing SQL exercises is important for improving your skills. Regular practice helps you get better at using SQL and boosts your confidence in handling different database tasks. So, in
15+ min read
Difference between SQL and T-SQL
SQL (Structured Query Language) is the standard language for managing and manipulating relational databases, enabling operations like querying, updating, and deleting data. T-SQL (Transact-SQL), an extension of SQL developed by Microsoft, adds advanced features and procedural capabilities specifically for SQL Server. In this article, We will learn
4 min read
QUOTENAME() Function in SQL Server
QUOTENAME() function : This function in SQL Server is used to return a Unicode string with delimiters added in order to make the string a valid SQL Server delimited identifier. Features : This function is used to find a Unicode string with delimiters added. This function accepts only strings and delimiters. This function add delimiters by default i
3 min read
Conversion Function in SQL
When you define expressions and local variables then you should specify what type of data will be stored in those objects such as text data, money, dates, numbers, or characters. Strings Data types such as CHAR and VARCHAR.Decimal values such as FLOAT and REAL.Binary String such as BINARY.Date and Time Data Types such as DATE, TIME, TIMESTAMP, and
4 min read
How SYSDATE function works in PL/SQL
The PLSQL SYSDATE function will returns current system date and time on your database. There is no any parameter or argument for the SYSDATE function. The SYSDATE function returns a date value. Note that the SYSDATE function return date and time as "YYYY-MM-DD HH:MM:SS" (string) or as YYYYMMDDHHMMSS (numeric). Syntax: SYSDATE Example-1: SELECT Sysd
2 min read
SESSIONPROPERTY() Function in SQL Server
SESSIONPROPERTY() function : This function in SQL Server is used to return the settings of the session that is specified in the argument section. Features : This function is used to find the settings of the session state.This function comes under Advanced Functions.This function accepts only one parameter namely option. Syntax : SESSIONPROPERTY(opt
2 min read
SQL | ENCRYPT Function
The SQL Encrypt function is used to encrypt a string using UNIX crypt(). The function is based on Unix crypt() system call, hence it returns NULL on Windows systems. The Encrypt function accepts two parameters which are the string and the salt to be encrypted. The Encrypt function returns a binary string. Syntax: ENCRYPT(string, salt) Parameters Us
2 min read
TRANSLATE() Function in SQL Server
TRANSLATE() function : This function in SQL Server is used to return the translated string of the string stated in the first argument of this function, when the characters stated in the characters argument of the above function are converted into the characters stated in the last argument i.e, translations. Features : This function is used to find
2 min read
RAWTOHEX Function in PL/SQL
The objective is to use the function RAWTOHEX in PL/SQL code. Purpose : This inbuilt function is beneficial for the conversion of a raw value into a character value in its hexadecimal format. Syntax : RAWTOHEX(x) where x - raw value to be converted to hexadecimal value and hexadecimal equivalent in the form of a string value is returned. Here may b
2 min read
SIN() and COS() Function in SQL Server
1. SIN() Function : The SIN() function returns the sine of a number. Syntax : SIN(number) Parameter : Required. A numeric value. number : It is a numeric value. Returns : It returns the float_expression of the sine of a number. Example-1 : When the argument holds a positive number. SELECT SIN(5); Output : -0.95892427466313845 Example-2 : When the a
1 min read
CHAR() Function in SQL
CHAR() : This function could be used to find the character based on the ASCII (American Standard Code for Information Interchange) code. CHAR() function do not support multiple integers as arguments. Syntax : SELECT CHAR(code); Note - Parameter code is mandatory, code evaluates to an integer value from 0 to 255. Example-1: SELECT CHAR(65) AS Result
1 min read
DATEADD() Function in SQL Server
DATEADD() function : This function in SQL Server is used to sum up a time or a date interval to a specified date, then returns the modified date. Features : This function is used to sum up a time or a date interval to a date specified. This function comes under Date Functions. This function accepts three parameters namely interval, number and date.
3 min read