Solved

Proper Case conversion with exceptions

Posted on 2004-03-24
2
1,045 Views
Last Modified: 2008-04-28
I am looking to create a UDF that converts a passed varchar(8000) to proper case, taking into account exceptions like MacDonald.  I have a template UDF that works without any "exception handling."  What I need to know is the best way to implement this "exception handling" (I place this in quotes as it is not your usual exception handling).

Two options I can think of are an array I would populate in the UDF or a temporary table I would also populate in the UDF.  All of the exceptions must be contained in the UDF.

Please provide advice as to the best approach and some sample code (I haven't done a whole lot with the SQL language in terms of string manipulation).  Right now I have a variable @pos indicating the current position in the string inside of a loop.

In addition, I would like to know if anyone has a decent-sized list of exceptions.  Names with apostrophes where the letter capitalized is after the apostrophe have been taken care of already.  Here are the exceptions I've found so far:

MacArthur
McGavley
McGrath
McGraw
McNeil
MacDonald
DeGuzman
DeJong
DellRosso
DeScenza
DiGirolamo
DiPietro
LaRose
LaRouche
0
Comment
Question by:labreuer
2 Comments
 
LVL 7

Accepted Solution

by:
ChrisFretwell earned 500 total points
ID: 10669491
I dont have a list for you, but want to remind you that not everyone with a name like those listed will upper case the letter after the de/le etc. I dont know the ratio of which is more common, but you wont please everyone with this method and likely will tick off a few.

Take a look in your local phone book for names like larose, dejong etc and you'll find a complete mix. The Mc and Mac are more standard than some of the others (who will often put a space in when they want to upper case  a weird part of it). Plus to make life more exciting, I know a few de{name} who spell it with the d lower case.

But, to add to your list, any name that you have with a Mc, you should check the same way for a Mac and vice versa.


0
 
LVL 1

Author Comment

by:labreuer
ID: 10690999
I came up with a list of one thousand names and then decided that, with the above said, that implementing special cases would be more trouble than it is worth.

If anyone still wants to come up with an answer to my first question, I'll split the points; otherwise I'll give ChrisFretwell a "B" (as he did not answer the first question).
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now