0

Here is the example which i want in output...

I have this input = "Automatic email sent"

But I want this output = "AutomaticEmailSent"

Thanks In Advance!

DavidG
  • 113,891
  • 12
  • 217
  • 223

3 Answers3

1

Use TextInfo.ToTitleCase

// Defines the string with mixed casing. 
string myString = "Automatic email sent";

// Creates a TextInfo based on the "en-US" culture.
TextInfo myTI = new CultureInfo("en-US",false).TextInfo;

// Changes a string to titlecase, then replace the spaces with empty
string outputString = myTI.ToTitleCase(myString).Replace(" ", "");
Waqas Raja
  • 10,802
  • 4
  • 33
  • 38
1

Stealing a function from this answer which takes an text input and make it proper case (otherwise known as title case):

create function ProperCase(@Text as varchar(8000))
returns varchar(8000)
as
begin
   declare @Reset bit;
   declare @Ret varchar(8000);
   declare @i int;
   declare @c char(1);

   select @Reset = 1, @i=1, @Ret = '';

   while (@i <= len(@Text))
    select @c= substring(@Text,@i,1),
               @Ret = @Ret + case when @Reset=1 then UPPER(@c) else LOWER(@c) end,
               @Reset = case when @c like '[a-zA-Z]' then 0 else 1 end,
               @i = @i +1
   return @Ret
end

Then you can combine this function with REPLACE:

SELECT REPLACE(dbo.ProperCase(column), ' ', '')
FROM MyTable
Community
  • 1
  • 1
DavidG
  • 113,891
  • 12
  • 217
  • 223
0

SQL Server

declare @value varchar(64) =  rtrim(' ' +  'Automatic email sent')
;with t(n) as (
    select n = charindex(' ', @value, 0)
    union all 
    select n = charindex(' ', @value, n + 1)
    from t
    where n > 0
)
select @value = stuff(@value, n + 1, 1, upper(substring(@value, n + 1, 1))) from t where n > 0
select replace(@value, ' ', '')
Alex K.
  • 171,639
  • 30
  • 264
  • 288