title: How to trim trailing 0 ASCII characters from a string in MS SQL Server
body: <p>I have a string of type <code>VARCHAR(128)</code> in MS SQL Server, which has this value: 'abc       '.</p>
  
  <p>However, these trailing "spaces" are not regular spaces (ASCII 32), they are of ASCII 0. I want to trim these trailing "spaces", but I could not get it to work.</p>
  
  <p>I have tried the following approaches:</p>
  
  <p><code>ltrim</code> and <code>rtrim</code></p>
  
  <pre><code>replace('abc       ', CHAR(0), '')
  
  substring('abc       ', 0, charindex(CHAR(0), 'abc       '))
  </code></pre>
  
  <p>But none of these seem to work as intended. </p>
  
  <p>How can I remove these trailing ASCII 0 characters from the string?</p>