Return a Camel Case Text in SQL
Following are the steps to return the Camel Case sentence in SQL
1. Execute the following procedure
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
2. Thats it …. run the the function
select dbo.[CamelCase] (‘HOW ARE YOU’)
3. Output
No comments:
Post a Comment