Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL Server
Expertise: Beginner
Oct 6, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Convert Text to Proper Case

I am using SQL Server 7 and would like to convert an uppercase string to proper case. Is there an easy way to do it?

SQL Server has several functions to allow you to manipulate the case of text characters. UPPER and LOWER convert text to their respective cases. The trick is to leave the first character as upper and just convert the rest. For that, you also need to use the substring function. The substring function allows you to pick pieces of a string. It takes three parameters: the string, start position, and number of characters.

Here is some sample code that I used first to convert the au_fname field in pubs.dbo.authors to uppercase and then convert it back into proper case:

update authors
set au_fname
= upper(au_fname)

select au_fname from authors

update authors
set au_fname =  upper(substring(au_fname,1,1)) + 

select au_fname from authors
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date