• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

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.
0
expertsexchangehunter
Asked:
expertsexchangehunter
  • 2
  • 2
1 Solution
 
momi_sabagCommented:
select lower(your_column)
from your_table

will return the name in all lower case
select upper(left(your_column,1)) + lower(substring(your_column,2, charindex(',', your_column) -1)) +
     upper(left(your_column, charindex(',', your_column)+1)) + lower(substring(your_column,charindex(',', your_COLUmn)+1, len(your_column)))
0
 
expertsexchangehunterAuthor Commented:
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,charindex(',', 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?
0
 
expertsexchangehunterAuthor Commented:
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
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now