Solved

Correcting Capitalization in a table

Posted on 2004-04-09
6
349 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?
0
Comment
Question by:jkalkowski
  • 4
6 Comments
 
LVL 3

Expert Comment

by:jayrod
ID: 10792674

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
0
 
LVL 3

Expert Comment

by:jayrod
ID: 10792687
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)))
0
 
LVL 3

Accepted Solution

by:
jayrod earned 50 total points
ID: 10792705
--Correction: took out extra parenthesis
update Table
set [column] = upper(substring([column], 1,1)) + lower(substring([column], 2, len([column])))
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 34

Expert Comment

by:arbert
ID: 10792741
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
0
 
LVL 3

Expert Comment

by:jayrod
ID: 10792799
thanks arbert.. I'll be using that UDF from now on if ya don't mind :)
0
 
LVL 1

Author Comment

by:jkalkowski
ID: 10792881
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
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question