Convert Text to Proper Case

Question:
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?

Answer:
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 authorsset au_fname= upper(au_fname)select au_fname from authorsupdate authorsset au_fname =  upper(substring(au_fname,1,1)) +      lower(substring(au_fname,2,datalength(au_fname)))select au_fname from authors

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS