Created
December 24, 2019 18:10
-
-
Save kristinaconley/71b9f5d505c86d7432ab7269e86c2c7b to your computer and use it in GitHub Desktop.
Camel Case Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
BEGIN | |
BREAK | |
END | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment