Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Proper Case conversion with exceptions

Posted on 2004-03-24
2
Medium Priority
?
1,102 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

610 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