Subject | Splitting a field |
---|---|
Author | Joe Martinez |
Post date | 2003-05-19T19:07:22Z |
Ok, let's say I have a table (Customers) with 3 varchar fields:
Wholename
Firstname
Lastname
Wholename contains names that are always in the following format:
John Smith
Peter Johnson
Mary Martin
etc...
That is, it's always first name, space, last name.
The Firstname and Lastname fields are currently empty. My task is to take
the Wholename field and split it up into Firstname and Lastname and set
them appropriately.
So, I basically have something like:
update Customers
set Firstname = ??????????????,
Lastname = ?????????????
I'm trying to figure out what to put in where the question marks are, based
on the Wholename fields. I want to do this with an SQL statement, rather
than writing a client app or stored procedure.
Does anyone know how this can be done?
Thanks,
Joe
Wholename
Firstname
Lastname
Wholename contains names that are always in the following format:
John Smith
Peter Johnson
Mary Martin
etc...
That is, it's always first name, space, last name.
The Firstname and Lastname fields are currently empty. My task is to take
the Wholename field and split it up into Firstname and Lastname and set
them appropriately.
So, I basically have something like:
update Customers
set Firstname = ??????????????,
Lastname = ?????????????
I'm trying to figure out what to put in where the question marks are, based
on the Wholename fields. I want to do this with an SQL statement, rather
than writing a client app or stored procedure.
Does anyone know how this can be done?
Thanks,
Joe