amarkhowe (8/28/2012)
Thanks you for your reply!I do not want to drop the table but split the name on to the same table in new columns?
That's just sample data.
Change the tablename in the query to the name of your table of names and addresses:
SELECT
Title= LEFT(Fullname,space1.pos-1),
Forename= SUBSTRING(Fullname,space1.pos+1,space2.pos-space1.pos-1),
Surname= SUBSTRING(Fullname,space2.pos+1,8000)
FROM MarksTableOfNamesAndAddresses
CROSS APPLY (SELECT CHARINDEX(' ', Fullname,1)) space1 (pos)
CROSS APPLY (SELECT CHARINDEX(' ', Fullname,space1.pos+1)) space2 (pos)[/code]
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden