Re: How to split a name field and write to Lname + Fname

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Adam Machanic (amachanic_at_hotmail._removetoemail_.com)
Date: 09/17/04


Date: Fri, 17 Sep 2004 19:05:26 -0400

You can try:

SELECT LEFT(YourCol, CHARINDEX(',', YourCol) - 1) AS LName,
    RIGHT(YourCol, LEN(YourCol) - CHARINDEX(',', YourCol) - 1) AS FName
FROM YourTable

"Pancho" <Pancho@discussions.microsoft.com> wrote in message
news:67313945-238A-416A-A5F0-4934C4494352@microsoft.com...
> I have a table EmployeeOffice with a field [Employee Name]. Values in
that
> field are like Smith, John, always separated by a comma. How can I read
the
> string up to (and excluding) the comma, store that value and SET my new
field
> Lname to be the value, and then move one space past the comma to collect
the
> remainder and SET my new field Fname to be the first-name string value?
> Thanks!



Relevant Pages

  • Re: search free formated field
    ... John / Smith ... If the string contains one or more slashes ... Else if the string contains a comma ...
    (microsoft.public.access.modulesdaovba)
  • Re: need to extract specific characters from field
    ... Extend the approach John S. provided. ... on the "inside" string. ... Beware, however, if there is NO space, you'll get an error. ... Those will both fail if the is no comma in your name field. ...
    (microsoft.public.access.queries)
  • Re: Last Name First
    ... it still doesn't work on John P. Henry. ... > Public Function NameFix(strName As String) As String ... >> middle initial (no space between comma and First name). ...
    (microsoft.public.excel.programming)
  • How to split a name field and write to Lname + Fname
    ... I have a table EmployeeOffice with a field. ... field are like Smith, John, always separated by a comma. ... remainder and SET my new field Fname to be the first-name string value? ...
    (microsoft.public.sqlserver.programming)
  • Re: Formatting Names
    ... LName, First AND Spouse ... First LName, Spouse Lname ... word which is followed by a comma, or a comma, or the ... But to do any more requires a complete definition of the various formats that ...
    (microsoft.public.excel.programming)