Very good answer by ClaireHsu, but if you want to move each part of the name into an new table where they reside in different columns,do it this way:
Insert into MyNewTable(FirstName,Lastname)
select left(Name,charindex(' ',Name)-1),
right(Name,len(Name)-charindex(' ',Name)) from mytable
Now if the 2 new columns will be in the same table as the table where the concatenated column is,you will do an update this is how you can do it:
--First add the new columns Firstname and lastname
ALTER TABLE Mytable ADD FirstName varchar(50),LastName varchar (50)
--Secondly add an identity column,you will drop this column later,this column will have autogenerated number from 1 to x depending on the number of rows you have in your table, if you already have an IDENTITY column use it.
ALTER TABLE Mytable ADD TempColmun int IDENTITY
--Decalre some variables
DECLARE @Counter int,@fname varchar(50),@lname varchar(50)
--initialize the counter
SELECT @Counter=1
--Loop through your table
WHILE @counter<=(select count(*)from Mytable)
BEGIN
--Split the name and get the firstname and lastname into
--variables
SELECT @fname=LEFT(Name,CHARINDEX(' ',Name)-1),
@lname=RIGHT(Name,len(Name)-CHARINDEX(' ',Name)) FROM mytable WHERE TempColumn=@counter
--Now update your table
UPDATE Mytable SET FirstName=@Fname,LastName=@LName
WHERE TempColumn=@counter
--Increment the counter
SELECT @Counter=@counter+1
END
--Now remove the temp column
ALTER TABLE MyTable DROP COLUMN TempColumn
--If you want to get rid of the concatenated field
ALTER TABLE MyTable DROP COLUMN Name
I hope this helps
Black Belt Sequelist