TSQL to Convert Upper Case to Sentence Case

This is a quick snippet showing how to convert a string to sentence case (first letter capitals and the rest lower case).

CREATE FUNCTION dbo.ConvertStringtoSentenceCase
(@InputString Varchar(max))
RETURNS varchar(max)

DECLARE @OutputString varchar(max)

SET @OutputString =  (
upper(substring(@InputString,1,1)) +

 RETURN @OutputString

Execute function like this …

SELECT dbo.ConvertStringtoSentenceCase('Convert This String to Sentence CASE')

A good post here from PinalDave showing how to convert to Title case http://blog.sqlauthority.com/2007/02/01/sql-server-udf-function-to-convert-text-string-to-title-case-proper-case/.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s