substring

i have a column that has "Full name" of an individual.

I want to create a new column with just the first name.

How do i populate this column with just the first name...ie it just takes the string until the space from the "full name" column.



Answer this question

substring

  • ChRiZ

    In common, there is no option to do so, there could be a surname which consists of three, four parts and a firstname which could habe one, two, three, four. How would you determine hwere the first name begins and the last name ends Thats like building a sum and then trying to split the original values off.

    HTH, jens Suessmeyer.


  • Calua

    Well i completely understand that.

    Lets just assume that the full name consists of just two words with one space, is there a better way


  • Spongebob34

    i figured out this but any better options are appreciated.

    substring (FullName,1,PATINDEX('% %', FullName))

    anyone knows an alternate please let me know.

    thanks


  • gtr1963

    Its hard to normalize the data after denormalizing it, cause you can’t determine where is the First and the Lastname: "Bob Joe Smith". YOu either have to decide if the Lastname begins after the first blank or before the last blank !

    HTH, Jens Suessmeyer.


  • substring