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
Solved

Proper Case conversion with exceptions

Posted on 2004-03-24
2
1,073 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

828 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