Credit to the Stack Overflow post here: http://stackoverflow.com/questions/230138/sql-server-make-all-upper-case-to-proper-case-title-casecreate function ProperCase(@Text as varchar(8000))returns varchar(8000)asbegindeclare @Reset bit;declare @Ret varchar(8000);declare @i int;declare @c char(1);select @Reset = 1, @i=1, @Ret = '';while (@i <= len(@Text))select @c= substring(@Text,@i,1),@Ret = @Ret + case when @Reset=1 then UPPER(@c) else LOWER(@c) end,@Reset = case when @c like '[a-zA-Z]' then 0 else 1 end,@i = @i +1return @Retend
Monday, 3 August 2015
Function to Proper Case a text string
The following function will capitalise the first letter of each word:
Subscribe to:
Post Comments (Atom)
Updating massive amount of rows whilst avoiding blocking
The following SQL is a good means to split an update on a massive table into smaller chunks, whilst reducing blocking. The method is to upda...
-
Microsoft Distributed Transaction Coordinator (abbreviated to MSDTC, or DTC) is usually very quick and simple to set up. However, it isn...
-
Migrations between SQL Servers can be laborious, and doing them manually leaves a lot of room for human error. Scripting a migration using t...
-
Scheduling SSIS packages from SQL Agent can produce the following error on a new installation of SQL Server: “Connecting to the Integration...
No comments:
Post a Comment