BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

SQL Server
SQL 2005+

SQL Server Case Conversion Functions

The forty-sixth part of the SQL Server Programming Fundamentals tutorial continues the discussion of Transact-SQL (T-SQL) string processing functions. This article describes two functions that allow text to be converted to upper or lower case.

String Case Functions

It can be useful to convert the case of text to highlight specific items in the output of a query or to prepare information that will be used within a report. Transact-SQL provides some limited functionality to allow text to be converted to either upper or lower case. Unfortunately it does not provide other functions to permit conversion to title case or sentence case. In this article we will examine the two case conversion functions.

Lower

The Lower function converts a string to lower case. The function accepts a single argument, which contains the text to be modified. The argument can be of a character or binary data type. As with the other string functions, Lower may be used with literal text, variables or column data. For simplicity, the example below converts a fixed string to lower case and outputs it using the PRINT command:

PRINT lower('BlackWasp')    -- blackwasp

Upper

The Upper function is used in the same manner as Lower. It returns a capitalised version of the input string.

PRINT upper('BlackWasp')    -- BLACKWASP
22 November 2009