1. In Microsoft SQL Server Management Studio, Select the Database and Create a New Query
Now Paste the following code. This will create a function.
CREATE FUNCTION dbo.TitleCaseText(@input NVARCHAR(4000)) RETURNS NVARCHAR(4000) AS BEGIN DECLARE @position INT WHILE IsNull(@position,Len(@input)) > 1 SELECT @input = Stuff(@input,IsNull(@position,1),1,upper(substring(@input,IsNull(@position,1),1))), @position = charindex(' ',@input,IsNull(@position,1)) + 1 RETURN (@input) END
2. To just display the contents of the column in Title case, use the following syntax
SELECT dbo.TitleCaseText(ColumnName) FROM TableName
3. To update the contents of the column to Title Case, use the following syntax
UPDATE TableName SET ColumnName = dbo.TitleCaseText(ColumnName)