Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

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.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date