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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Fullname split

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2008-03-28 : 15:27:04
Guys,

I have to split fullname into first name and last name - I was not able to do it substring is there any to do this?

Name Fname Lname
______________________________________
smith, john john smith
doe, john john doe

Any suggestions and inputs would help

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-28 : 15:47:47
[code]SELECT name,
CASE WHEN CHARINDEX(',',Name) > 0 THEN SUBSTRING(Name,CHARINDEX(',',Name)+1,LEN(Name)-CHARINDEX(',',Name)) ELSE '' END AS Fname,
CASE WHEN CHARINDEX(',',Name) > 0 THEN LEFT(Name,CHARINDEX(',',Name)-1) ELSE Name END AS Lname
FROM YourTable[/code]
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-03-28 : 23:59:20
http://sqlblindman.googlepages.com/formatname

e4 d5 xd5 Nf6
Go to Top of Page
   

- Advertisement -