Home Forums Programming General Splitting a column into Fname Lname RE: Splitting a column into Fname Lname

  • I rather like SimonSabin's approach.

    It would allow you to handle more special cases such as multiple spaces, single names and counting the number of tokens to determine if their number is what you are expecting. It could either fix these issues on the fly or flag those particular records as a problem.

    Also, I usually like to do an LTRIM(RTRIM()) on the full name to clear out any leading/trailing spaces before any other processing occurs. Seems to me when I've done this before I've included a routine to convert any multiple spaces to single spaces. (Recursively converting two spaces to one until no replacements are made.)

    With this type of data scrubbing it's rare that you can handle all the special cases. I try to catch what I can and then keep in mind that even if I miss some of them it's far more accurate than before I started. Besides, there's always some salesperson/marketingish person who will come along later and point out your failings.


    "I met Larry Niven at ConClave 27...AND I fixed his computer. How cool is that?"
    (Memoirs of a geek)