THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Greg Low (The Bit Bucket: IDisposable)

Ramblings of Greg Low (SQL Server MVP, MCM and Microsoft RD) - SQL Down Under

Converting T-SQL strings to Proper Case, Camel Case, Snake Case, or Kebab Case

Often when I’m moving data around (usually with SSIS but also with just T-SQL), I need to take text that is all capitalized or simply has messed-up capitalization, and convert it to something that looks better (and more human readable) in the target system.

The most common option for me is conversion to Proper Case. Here’s an example. Let’s start with the following text:




On a webpage or report, that’s going to look downright ugly. In the March 2017 update to SDU_Tools, we added functions to do all of the above. SDU Tools is a free library for SQL Server developers and DBAs. You can easily just add it to your database, then call the functions as needed. The functions get added in a separate schema and are easy to remove later if you ever wish to. (We hope you won’t want to). They’re also easy to upgrade. You’ll find info here:

Let’s look at the output from the function:


The function has been built to allow for common capitalization rules in names and addresses. Here’s another example:



While Proper Case is useful, it’s not always what’s needed. Let’s look at the difference with a book title:


The key difference with Title Case is that minor words like “for”, “and”, “to”, etc. aren’t capitalized.

While we were adding these functions, we also decided to add a few other common ones. Snake case and Kebab Case look like this:



Note that in Snake Case, the words are all lower-cased and any whitespace between the words is replaced by a single underscore.

In Kebab Case, every word is capitalized and dashes (hyphens) are inserted between the words.

We hope you’ll find these functions useful. More details are here:

Published Friday, April 7, 2017 10:53 AM by Greg Low

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS


No Comments

Leave a Comment


This Blog



No tags have been created or used yet.


Privacy Statement