Link to home
Start Free TrialLog in
Avatar of webdork
webdork

asked on

SQL server split column

In SQL Server:

I've got a FullName column formatted like:
Smith, Tom

I want to split out the values to separate columns:

FirstName
LastName
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webdork
webdork

ASKER

Ok it works... One thing though it places the first name in the LastName column and vis versa. Can you redo with SQL?
just interchange the column names''UPDATE urTable SET
LastName=  SUBSTRING(FullName,1,CHARINDEX(',',FullName)-1),
FirstName =  LTRIM(SUBSTRING(FullName,CHARINDEX(',',FullName)+1,LEN(FullName)))
Avatar of webdork

ASKER

Thank You