SQL UPPER Function | Convert Text to Uppercase

SQL UPPER is an inbuilt Function in SQL Server. It converts a text to uppercase. In this article, we will discuss the SQL UPPER Function. Also, we will discuss a few examples of using it.

Also, you can convert text to lowercase in SQL Server using the LOWER Function.

Syntax

UPPER (string)

Parameters

The Function expects only one parameter. You need to pass the string you need to convert in uppercase as the parameter.

Return Value

The function returns the input string to uppercase in SQL Server.

MySQL Upper Function Diagram

Support

The function works in SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse and Parallel Data Warehouse.

Examples

Let’s see some examples to use the function in queries.

Example 1: Basic Query

You can use the UPPER Function to convert a string to uppercase in SQL Server.

SELECT UPPER('bringing knowledge together') as UpperCase;
+-----------------------------+
| UpperCase                   |
+-----------------------------+
| BRINGING KNOWLEDGE TOGETHER |
+-----------------------------+
1 row in set (0.00 sec)

Example 2: SELECT Query

You can use the Upper Function in SELECT statements.

select UPPER(user_name) as UpperUserName from user_description;
+---------------+
| UpperUserName |
+---------------+
| CHANDLER      |
| MONICA        |
| ROSS          |
+---------------+
3 rows in set (0.00 sec)

Example 3: UPDATE Query

You can also update the existing fields in a table using the function in an UPDATE Query.

UPDATE user_description SET user_name = UPPER(user_name);
Query OK, 3 rows affected (0.07 sec)
Rows matched: 3  Changed: 3  Warnings: 0

select user_name from user_description;
+-----------+
| user_name |
+-----------+
| CHANDLER  |
| MONICA    |
| ROSS      |
+-----------+
3 rows in set (0.00 sec)

Conclusion

In this article, we discussed the UPPER Function. It converts a text to uppercase in SQL Server. You can read more about it on the Official Microsoft Documentation. Also, read more about SQL Server on Concatly.

Also, you can convert text to lowercase using SQL Server LOWER Function.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *