October 25, 2010 at 10:08 pm
Comments posted to this topic are about the item Change String to Title Case(Initcap)
October 26, 2010 at 1:14 pm
This is a very simplistic implementation of a function that would be very useful if fully implemented. Unfortunately it doesn't take into account the myriad of language-specific exceptions to title case. In English, typically you don't "upper case" the first letter of words like "of" and "and". You don't lower case the 2nd/3rd letters of some Celtic surnames (eg. McCall or O'Toole). Sometimes you don't lowercase the first letter after a hyphen (eg. Guinea-Bissau). I'm sure there's more, it's a bit mind-blowing when you get into it!
James McCall
October 28, 2010 at 8:35 pm
Thanks for the useful script!
However, I noticed that you used:
Select @vString = Replace(@vString, @vWord, '')
This replaces _all_ occurrences of @vWord in @vString, eliminating repeated words in the title.
I fixed this using:
Select @vString = RIGHT(@vString, LEN(@vString) - LEN(@vWord))
This will just strip the first word from the string, which I believe was the intended behaviour.
Cheers,
David Scheppers.
November 3, 2010 at 8:41 am
Like any TSQL function that iterates through strings, this will run fine on small sets or a single field, but if you're going to use this in large set queries, you might want to consider writing it as a CLR assembly: C# or VB.Net are faster at string parsing.
May 18, 2016 at 7:10 am
Thanks for the script.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy