Blog Post

T-SQL UPPER(): Change an all lowercase string to uppercase

The T-SQL UPPER() command allows you to change a lowercase string to an uppercase string.

For example, it will allow you to change the word hello to HELLO.

Example 1:

Declare @MyVar varchar(50);

Set @Myvar=’hello’;

Select UPPER(@MyVar)   => Output will be HELLO in uppercase.

You can use the T-SQL UPPER() command with other commands to Capitalize only the first letter of a word.

For example, change florida to Florida.

Example2:

DECLARE @MyVar varchar(50);

SET @Myvar=’florida’;

SELECT UPPER(LEFT(@MyVar,1)) +SUBSTRING(@MyVar,2,49)

Since my string is of length 50, notice that I am selecting the first letter and converting it to upper case and concatenating with the rest 49 letters that are already in lowercase starting with the second position in the string.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating