Separate camel case String
Below is the query to separate camel case string and removing first lower part from the string on condition IF @skipFirstLowerPart = 0 means skip first lower part from the string and IF @skipFirstLowerPart = 1 then do not skip first lower part from the string DECLARE @str VARCHAR ( 100 ) = 'txtFirstName' DECLARE @skipFirstLowerPart INT = 0 -- 0 yes 1 no DECLARE @len INT = LEN ( @str ), @ptr INT = 1 , @chk INT = 0 DECLARE @newstr VARCHAR ( 100 ) = '' WHILE @len > 0 BEGIN DECLARE @char CHAR ( 1 ) = SUBSTRING ( @str , @ptr , @ptr + 1 ) IF @skipFirstLowerPart = 0 BEGIN IF ( CONVERT ( VARBINARY ( 128 ), @char ) = CONVERT ( VARBINARY ( 128 ), LOWER ( @char ))) AND ( @chk = 0 ) BEGIN SET @char = '' END END IF CONVERT ( VARBINARY ( 128 ), @char ) <> CONVERT ( VARBINARY ( 1