Split string

  • Hi all,

    My Source is excel which contains Name Column and I need to insert that column by splitting as below. Please suggest idea.

    I want to split full name into lastname,FirstName and middlename. Below is scenario:

    Name : Pawar, Ramesh S.

    Then I want to split as below:

    LastName FirstName MidddleName

    Pawar Ramesh S

    i.e. Upto comma in a string it is last name, after comma till space it is a first name and after space it is a last name.

    Please help.

    Thanks

    Abhas.

  • If the names really are formatted perfectly, you should be able to create derived columns to do this for you.

    But I'll bet that they are not all quite so well formatted :w00t:

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Names are well formatted.

    Thanks

  • abhas (2/4/2015)


    Names are well formatted.

    Thanks

    Then you are onto a winner. Try with the derived column idea and post back with any further problems.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Thanks Phil for your suggestion. I am able to split lastName as Pawar by using below code of stuff.

    SUBSTRING(Name,1,FINDSTRING(Name,",",1) - 1)

    but not able to identify FirstName as Ramesh. M trying on that

    Thanks

    Abhas.

  • abhas (2/4/2015)


    Thanks Phil for your suggestion. I am able to split lastName as Pawar by using below code of stuff.

    SUBSTRING(Name,1,FINDSTRING(Name,",",1) - 1)

    but not able to identify FirstName as Ramesh. M trying on that

    Thanks

    Abhas.

    Good stuff. To get Ramesh, you need to do something like this:

    1) Find the position of the comma.

    2) Find the position of the space, starting searching from the position of the (comma + 1).

    3) Extract the string between (1) + 1 and (2)

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply