UPPER() function in SQL Server
UPPER() :
This function in SQL Server helps to convert all the letters of the given string to Uppercase. If the given string contains special characters or numeric values, then they will remain unchanged by this function.
Syntax :
UPPER( str )
Parameters :
- str – The string which will be converted to uppercase
Result :
This function will return the uppercase string.
Example-1 :
Using UPPER() function with Lowercase string.
SELECT UPPER('be patience be awake') As New;
Output :
New |
---|
BE PATIENCE BE AWAKE |
Example-2 :
Using UPPER() function with Mixed case string.
SELECT UPPER('EvERy DAy iS A NEW day') As New;
Output :
New |
EVERY DAY IS A NEW DAY |
Example-3 :
Using UPPER() function with Select statement.
Create Players table and Insert value in it.
Create table Players ( Firstname varchar(40), Lastname varchar(40), Country varchar(40) )
Inserting data into players :
Insert into Players values ('Kane', 'Williamson', 'New Zealand')
The table will look like.
Firstname | Lastname | Country |
---|---|---|
Kane | Williamson | New Zealand |
Use of UPPER() function.
SELECT Firstname, UPPER(Lastname) As New_name, Country FROM Players;
Output :
Firstname | New_name | Country |
---|---|---|
Kane | WILLIAMSON | New Zealand |
Example-4 :
Using UPPER() function in a Variable.
DECLARE @text VARCHAR(45); SET @text = 'be happy be light '; SELECT @text, UPPER(@text) AS Upper;
Output :
Text value | Upper |
---|---|
be happy be light | BE HAPPY BE LIGHT |
Contact Us