?
Solved

Proper Case conversion with exceptions

Posted on 2004-03-24
2
Medium Priority
?
1,091 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
ChrisFretwell earned 1500 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

764 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