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
 SQL Server Development (2000)
 How do I split a NAME in one column

Author  Topic 

cs_bhimavarapu
Starting Member

23 Posts

Posted - 2002-07-29 : 15:14:32
I have an employee name as "WATERFIELD,JADE CRYSTAL" in one of the columns of a table. My requirement is to split this name in one column into First name, middle name and last name. Do we have a function to identify a string before the first occurence of a ',' in a string? Or Is there any other easy procedure. I have to do this for 5 million records....

Thanks in advance!!!


Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-29 : 15:27:52
There is no built in function. You'll have to roll your own with the string functions in T-SQL

update
dbo.mytable
set
lastname = left(fullname,charindex(',',fullname)-1),
firstname = substring(fullname,charindex(',',fullname)+1,charindex(' ',fullname) - charindex(',',fullname)),
middlename = reverse(left(reverse(fullname),charindex(' ',reverse(fullname))-1))

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -