Squeeze Function
The Squeeze function is used to remove the multiple occurences of spaces into one occurence. In SQL Server there is no function to do the same. I needed to write this in my application to remove unwanted spaces in the string.
Run the following and see the result
declare
@t table(string_col varchar(100))
insert into @t
select 'a b c' union all
select 'a b c' union all
select 'a b c' union all
select 'a b c' union all
select 'a b c'
select
string_col
,
replace
(replace(replace(string_col,' ',' ~!#$^'),'~!#$^ ',''),'~!#$^','') as new_string_col
from
@t
If you use front end application (VB,.NET,jave,etc), you can also simulate the same approach there