Link to home
Start Free TrialLog in
Avatar of CementTruck
CementTruck

asked on

Need help converting 2 columns to proper case in SQL Server 2005.

I have 2 columns in an SQL database table, LastName, and FirstName. The information entered is all mixed case. I have i.e. JOHN SMITH,  jane doe, John Doe. Is there any way for me to run a query on  those 2 columns and correct the case to proper case? I would also like to create a backup plan, like copy this table and rename it, just in case the original table gets toasted accidentally.
Avatar of dready
dready

Hi,

here you can find a user defined function to Propercase a string:

http://pscode.com/vb/scripts/ShowCode.asp?txtCodeId=780&lngWId=5

you can use it in this form

update myTable set LastName = fn_PROPERCASE_All(LastName), firstName = fn_PROPERCASE_All(FirstName).

To make a backup of your tables, you can do

SELECT * INTO myTable_backup
FROM myTable

this will create the table myTable_backup and copy all the data there.

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of ksaul
ksaul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did either of these two suggestions work for you?