We have predefined functions to convert a string columns or string literals to different cases in SQL Server. To convert everything to lower case we could use Lower() function and to convert everything to upper case we could use UPPER() function. There is no predefined function for Title case or capitalize the first letter and decapitalize the remaining part of the string we could use a combination of the Lower() and Upper() functions.
Let us see how we could change cases in action:
SELECT [FirstName] AS [Original FirstName] ,[LastName] AS [Original LastName] ,LOWER([FirstName] ) AS [LOWER FirstName] ,UPPER([LastName] ) AS [UPPER LastName] ,UPPER(LEFT([LastName],1)) + LOWER(RIGHT([LastName], LEN([LastName])-1)) AS [TitleCase LastName] FROM [AdventureWorks].[Person].[Person];
The third row decapitalize everything for first name column using Lower() function and the fourth column capitalize everything using Upper() function. To convert last names to title case we took the first letter of the column and capitalized it using Upper() function. To decapitalise the remaining text we strip out the first letter and apply Lower() function. Finally we merge them together.