Convert Text to Proper Case

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 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

See also  Monetize TikTok For Your Business

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist