SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

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.


DECLARE @MyVar varchar(50);
SET @Myvar=’florida’;

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.


No comments.

Leave a Comment

Please register or log in to leave a comment.