Transposing and capitalising col

  • I have a table which contains a column of name data in the format of:-

    DAVIDSON P E

    FORBES GE

    GRANT C

    etc

    (I don't know why there are variable spaces between the surname and initials)

    What I want is:-

    P E Davidson

    G E Grant

    C Forbes

    etc

    I've converted to LOWER and got stuck playing around with STUFF - has anyone done something similar?

  • Depending on the names you have, you may not be able to do much. Some surnames can have spaces in them.

  • The problem you face is GIGO

    Garbage In, Garbage Out.

    Although not always under your control, the cleanliness of the data should be part of the front end.

    You have to evaluate whether it is worth your time spending a ton of time "Fixing" your data if its just going to keep coming in incorrectly formatted. you may find you end up spending 40 or more hours and still not getting everything fixed correctly.

    A quick search in the scripts section of this site returned a function you can use to properly capitilize your names.

    As far as re-arranging them and fixing spaces you may need to extend the functionality of the function.

    http://www.sqlservercentral.com/scripts/Miscellaneous/31914/

Viewing 3 posts - 1 through 2 (of 2 total)

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