• Post Categories

  • Browse Blogs

  • Blog Stats

    • 450,649 hits
  • Syndications

    SQLServerPedia Contributor

T-SQL LOWER(): Change an all uppercase string to lower case

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

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

Example 1:

Declare @MyVar varchar(50);
Set @Myvar=’HELLO’;
Select LOWER(@MyVar)   => Output will be hello in lowercase.

You can use the T-SQL LOWER() 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 LEFT(@MyVar,1) +SUBSTRING(LOWER(@MyVar),2,49)

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

One Response

  1. Brilliant and short.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: