• Post Categories

  • Browse Blogs

  • Blog Stats

    • 624,384 hits
  • Syndications

    SQLServerPedia Contributor

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.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: