sql server - T-Sql function to convert a varchar - in this instance someone's name - from upper to title case? -
Do anyone find a function in their back pocket that can get it?
The result from: -
make the function proper (@ varchar (8000) as text) as varchar (8000) Declare starting @ reset bit; Announce @rate varchar (8000); Announce @Inte; Declared @ c char (1); Select @Reset = 1, @I = 1, @reset = ''; Select (@i & lt; = len (@Text)) @ c = substring (@ text, @ i, 1), @rate = @reset + case when @reset = 1 then UPPER (@c) else LOWER (@ C) end, @reset = case when '[a-zA-Z]' like @C, then 0 and 1 end, @ i = @i +1 return @ rate end
select dbo.propercase ('All UPPERCASE'); - Select all uppercase dbo.propercase ('MiXeD CaSe'); - Select composite episode dbo.propercase ('lower case'); - Select lower case dbo.propercase ('name with apostrophe - MR O'Reilly'); - Name with Apostofe - Select Mr. O Reilly dbo.propercase ('name with hyphen-marie two barrels'); - name with hyphen - my two barrel
Comments
Post a Comment