expertsexchangehunter
asked on
How can I make the following always return in proper case? First Character to upper case.
How do I change a first and last name that are in uppercase to Proper or Title case where the first character of the first and last name are capitol and the rest lower case. This is done in a Stored Procedure. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
momi
Here is my code
select upper(left(FirstName,1)) + lower(substring(FirstName, 2, charindex(',', FirstName) -1)) +
upper(left(LastName, charindex(',', LastName)+1)) + lower(substring(LastName,c harindex(' ,', LastName)+1, len(LastName)))
here is what happened when I ran it with a valid First and Last name
Invalid length parameter passed to the substring function.
What is wrong with my code?
Here is my code
select upper(left(FirstName,1)) + lower(substring(FirstName,
upper(left(LastName, charindex(',', LastName)+1)) + lower(substring(LastName,c
here is what happened when I ran it with a valid First and Last name
Invalid length parameter passed to the substring function.
What is wrong with my code?
ASKER
I used
select upper(left(FirstName,1)) + lower(substring(FirstName, 2, len(FirstName)-1)) + ' ' +
upper(left(LastName,1)) + lower(substring(LastName,2 , len(LastName)-1))
to get the desired results
select upper(left(FirstName,1)) + lower(substring(FirstName,
upper(left(LastName,1)) + lower(substring(LastName,2
to get the desired results
http://weblogs.sqlteam.com/jeffs/archive/2007/03/09/60131.aspx