Sunday , 25 June 2017
Home » SQL » Capitalizing first word in SQL Server

Capitalizing first word in SQL Server

Capitalizing first word in SQL Server

In this article I am going to show you how to use simple function in SQL Server to manipulate with your texts or strings. Imagine Lowercase uppercaseyou have a bunch of texts in lowercase and they all need to be uppercase or vice versa? You will have to rewrite all that boring thing one by one? Well in SQL Server there is a built-in function that does this conversion for you. Lets say that you want to capitalize every first word. Unfortunately SQL Server has no built-in function for that. You will have to create your own scalar function for that. In this article you will learn how to create that function.

First let me show you how to use the built-in function of SQL Server for uppercase and lowercase

The function name for uppercase is “upper” and for lowercase is “lower”. Now let’s see how this function is used.

Run this query above and you will see that all the lowercase will be converted into uppercase.

The query below is going to convert all uppercase letters into lowercase.

As I mentioned above for the capitalization of first word you have to create your own function. To create this function type the following query and run. I will name this function as ‘CapFirstWord’

After you create the function above, you can use this in the following way:

See the result in the picture below.
Capitalizing first word in SQL Server

Check Also

Stored Procedure vs Functions

Stored Procedure vs Functions In this article I am going to show you the differences …

Leave a Reply

Your email address will not be published. Required fields are marked *