Forum Moderators: open

Message Too Old, No Replies

Writing and Executing Batch Code

SQL Server 2000

         

Argblat

3:29 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



Hi all....

I have a SQL Server 2000 database table containing employee information [First Name, Last Name, etc etc].

Half of the Name information is the way it should be "John Doe" ... However the other half is ALL CAPS "JOHN DOE". What I would like to do is change all the First and Last Names to first letter capitalized, remainder lowercase.

I have an understanding of the programatic concepts involved in taking the string and changing everything after the first character to lowercase.

My issue is how to do this within the database.

What are my options? ... can I do it using pure SQL statements? ... can I do it using C#? ...

Please forgive me for not currently having the knowledge to accomplish this task, and help me to learn an important database/programming lesson

thanks
Mike

syber

4:41 pm on Dec 16, 2005 (gmt 0)

10+ Year Member



Something like this would get most of what you want, but wont't help you with last names like McPherson or O'Keefe


UPDATE employees
SET lastname = SUBSTRING(lastname,1,1) + LOWER(SUBSTRING(lastname,2,100))
WHERE ASCII(SUBSTRING(lastname,2,1)) < 91