Using Lower to ensure everything but the first letter of a name is capitalised

  • Hello all,

    I have the following script that sets the First letter of a word to uppercase. Is there anything I can do to make everything but the first letter lowwer case where I get for Example SMITH. I can set it to Smith?

    SELECT 'sMITH' = upper ( left ( 'sMITH' ,1 ) ) + right ('sMITH', len('sMITH')-1 )

    Thanks

    Debbie

     

  • Hi,

    All you need is a slight change to your code.

    select

    upper(left('smith',1)) + lower(right('smith',len('smith')-1))

    Regards,

    Ian.

  • select upper(left('smith',1)) + lower(substring('smith',2, 8000))

     


    N 56°04'39.16"
    E 12°55'05.25"

  • Ah I see. So the -1 means everything but the first character.

    Thanks for that!

    Debbie

     

  • Im being a bit stupid but how does ,2, 8000 work?

    Debbie

  • The '2' means start at position no. 2 and the 8000 means all the way to position 8000, that is, all characters from 2 to 8000.

    Please be aware that this will not work for names like McGrath, MacPherson, etc.

    HTH

    Paul

  • And once you code for those, invariably someone in the company will bring up that you need to deal with "O'", "von" (sometimes there is no space between that and the rest of the last name), "van der", and the like. Of course, coding for these is tricky, as code that properly handles MacFarland will likewise return MacElli. Many businesses just give up and stick with initial caps across the board.

    Fun stuff, speaking from experience.

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

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