AppDividend
Latest Code Tutorials

SQL Upper Function Example | MySQL And SQL Server Upper()

0

SQL UPPER function is used for converting all the characters in the source string to Uppercase characters. If any number is present in the string, then it remains unaffected. SQL UPPER() function converts a string to the upper-case.

SQL upper() Function

Suppose you have the online shopping website. Customers visit the website and provide the necessary information while creating the login account.

Each customer provides few compulsory information such as first name, last name, phone number, email address, and residential address.

Each customer is different, so you cannot expect the similar format for all inputs.

For example, you get a following entries in an SQL table.

We do not see all words following the consistent pattern.

It does not look good as well if you have to share the report daily to higher management for all newly enrolled customers.

The SQL UPPER function converts all the letters in a string into uppercase. If you want to convert the string to lowercase, you use the LOWER function instead.

Syntax

SELECT UPPER (String);

Parameters

String: The source string whose characters have to be replaced with Uppercase characters. It can be any literal character string, variable, character expression, or any table column.

Example

Query 1

SELECT UPPER (‘AppDividend.Com’);

Output

APPDIVIDEND.COM

Query 2

SELECT UPPER (‘sql123sql’);

Output

SQL123SQL

As discussed above, numbers remain unaffected to UPPER function.

Let’s apply the UPPER function to a table.

Table: Employee

Emp_id Emp_name City State Salary
101 Rohit Patna Bihar 30000
201 Shivam Jalandhar Punjab 20000
301 Karan Allahabad Uttar Pradesh 40000
401 Suraj Kolkata West Bengal 60000
501 Akash Vizag Andhra Pradesh 70000

 

Suppose we want to change the characters of the City of each employee to Uppercase, then the following query has to be written.

Query 3

SELECT Emp_name, City, UPPER (City) 
AS UPPER_CITY from Employee;

Output

Emp_name City UPPER_CITY
Rohit Patna PATNA
Shivam Jalandhar JALANDHAR
Karan Allahabad ALLAHABAD
Suraj Kolkata KOLKATA
Akash Vizag VIZAG

 

As you can see above, the name of the city is converted to Uppercase characters.

MySQL UPPER() Function

In MySQL, the UPPER() function converts a string to upper-case.

Syntax

UPPER(text)

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

SQL Server UPPER() Function

The UPPER() function converts an input string into uppercase.

Syntax

The following shows the syntax of the UPPER() function:

UPPER(string)

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

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

SQL Server UPPER() function returns the uppercase form of the input string.

Using the UPPER() function with literal strings

See the following query.

SELECT 
    UPPER('appdividend') result;

See the output.

result

APPDIVIDEND

Finally, SQL Upper Function Example | MySQL And SQL Server Upper() Tutorial is over.

Recommended Posts

SQL UNICODE Function

SQL Replicate Function

SQL Left Function Example

SQL Format Function

SQL LTRIM Function

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.