title: Replace duplicate spaces with a single space in T-SQL
body: <p>I need to ensure that a given field does not have more than one space (I am not concerned about all white space, just space) between characters.</p>
  
  <p>So</p>
  
  <pre><code>'single    spaces   only'
  </code></pre>
  
  <p>needs to be turned into </p>
  
  <pre><code>'single spaces only'
  </code></pre>
  
  <p>The below will not work</p>
  
  <pre><code>select replace('single    spaces   only','  ',' ')
  </code></pre>
  
  <p>as it would result in </p>
  
  <pre><code>'single  spaces  only'
  </code></pre>
  
  <p>I would really prefer to stick with native T-SQL rather than a CLR based solution.</p>
  
  <p>Thoughts?</p>