We help IT Professionals succeed at work.

Correcting Capitalization in a table

jkalkowski
jkalkowski asked
on
Medium Priority
400 Views
Last Modified: 2012-08-13
I have a name database that has gotten a bit sloppy over time.  Some name enteries are all upper case, some are all lower case and others are correct.  My table is called master_name.  I am looking for a command to make the first character upper case and the rest lower.

update.dba.master_name
SET last_name??????????

How can I do this?
Comment
Watch Question

Commented:

update employee_master
set fname = char(ASCII(substring(fname, 1,1)) + 32) + substring(fname, 2, len(fname))

be extremely careful with this update statement... test everywhere first

Commented:
whoops.. here is an easier one... that makes more sense


update employee_master
set fname = upper((substring(fname, 1,1))) + lower(substring(fname, 2, len(fname)))
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Top Expert 2004

Commented:
Here's a UDF that we use to do the job:

http://vyaskn.tripod.com/code/propercase.txt


Just remember, any weird names like McHenry will usually be a problem....

Brett

Commented:
thanks arbert.. I'll be using that UDF from now on if ya don't mind :)

Author

Commented:
perfect jayrod....U just cut and pasted, changed the [column] to read lname and it worked great.  Also Brett, good point about those pesky Irish names :-)  Actually I found a few D'Angelo's that it will effect also but I'd rather have the majority look neat!

Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.