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