0

Possible Duplicate:
SQL Server: Make all UPPER case to Proper Case/Title Case

if i have a string "HELLO WORLD"

How can i lowercase every letter after the first one but keep the camel casing so: i get:

Hello World

Community
  • 1
  • 1
William
  • 113
  • 1
  • 1
  • 4

1 Answers1

0

If possible, I would try to do this on the client personally... But you could try this:

CREATE FUNCTION [dbo].[CamelCase]
(@Str varchar(8000))
RETURNS varchar(8000) AS
BEGIN
  DECLARE @Result varchar(2000)
  SET @Str = LOWER(@Str) + ' '
  SET @Result = ''
  WHILE 1=1
  BEGIN
    IF PATINDEX('% %',@Str) = 0 BREAK
    SET @Result = @Result + UPPER(Left(@Str,1))+
    SubString  (@Str,2,CharIndex(' ',@Str)-1)
    SET @Str = SubString(@Str,
      CharIndex(' ',@Str)+1,Len(@Str))
  END
  SET @Result = Left(@Result,Len(@Result))
 RETURN @Result
END
Brian MacKay
  • 31,133
  • 17
  • 86
  • 125