MS SQL replace sequence of same characters inside Text Field (TSQL only)
- by zmische
I have a text column varchar(4000) with text:
'aaabbaaacbaaaccc' and I need to remove all duplicated chars - so only one from sequence left:
'abacbac'
It should not be a function, Procedure or CLR - Regex solution. Only true SQL select.
Currently I think about using recursive WITH clause with replace 'aa'-'a', 'bb'-'b', 'cc'-'c'.
So recursion should cycle until all duplicated sequences of that chars would be replaced.
DO you have another solution, perhaps more Permormant one?
PS: I searched through this site about different replace examples - they didnt suit to this case.