Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Split Name Field and format to Proper Case

Author  Topic 

VJG
Starting Member

17 Posts

Posted - 2012-08-17 : 11:04:51
Guys, thanks in advance,

I have a field named [FirstName] in which names are stored as JOE ALLEN, VICTOR J, MARK LEE and DONALD M.

I'm trying to split the name into to fields; [FirstName] and [MiddleName]

substring(Firstname,1,charindex(' ', Firstname)-1) FirstName,
substring(FirstName,charindex(' ', Firstname)+1,len(Firstname)) MiddleName

i used the above script to split them into the two fields, but is there a way to Have it Properly formatted?

Example: Id like to be have it show the results as Joe Allen, Victor J, Mark Lee and Donald M.

is this possible?

thanks in advance!!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-17 : 11:08:45
Madhivanan to the rescue here: http://beyondrelational.com/modules/2/blogs/70/posts/10901/tsql-initcap-function-convert-a-string-to-proper-case.aspx
Go to Top of Page

VJG
Starting Member

17 Posts

Posted - 2012-08-17 : 16:45:02
thank you!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-09-03 : 10:12:12
quote:
Originally posted by sunitabeck

Madhivanan to the rescue here: http://beyondrelational.com/modules/2/blogs/70/posts/10901/tsql-initcap-function-convert-a-string-to-proper-case.aspx


But by linking that link, you have rescued the OP

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -