• Post Categories

  • Browse Blogs

  • Blog Stats

    • 639,243 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 comment

Design a site like this with WordPress.com
Get started