Subject Re: Splitting a field
Author Alexander V.Nevsky
--- In ib-support@yahoogroups.com, Joe Martinez <joe@j...> wrote:
> 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?


Joe, think about usage of existing UDFs or writing own for this
purpose. But I think it is design mistake - it is more logical and
simply to store FirstName and LastName and make WholeName computed
column.

Best regards, Alexander.