I have table Customers:
Name
David Smith
John David
Jonathan Greg
and i want to transfer it to table Customers2 :
Name Surname
David Smith
John David
Jonathan Greg
How can i split those names into Name/Surname?
Thank you
I have table Customers:
Name
David Smith
John David
Jonathan Greg
and i want to transfer it to table Customers2 :
Name Surname
David Smith
John David
Jonathan Greg
How can i split those names into Name/Surname?
Thank you
Perhaps this but a space better be the deliminator...
Create table customers2 (
SELECT PARSENAME(REPLACE(Name, ' ', '.'), 2) AS [FirstName],
PARSENAME(REPLACE(Name, ' ', '.'), 1) AS [LastName]
FROM Customers)
Assuming it is strictly name + surname, you can do this
SELECT PARSENAME(REPLACE('David Smith', ' ', '.'), 1) AS NAME,
PARSENAME(REPLACE('David Smith', ' ', '.'), 1) AS SURNAME