title: SQL REPLACE function, how to replace single letter
body: <p>My code is as follows:</p>
  
  <pre><code>REPLACE(REPLACE(cc.contype,'x','y'),'y','z') as ContractType,
  </code></pre>
  
  <p>This REPLACE's correctly what I would like, but it unfortunatley changes all "z's" to "y's" when I would like </p>
  
  <p>x > y<br>
  y > z</p>
  
  <p>Does this make sense? I would not like all of the new Y's to then change again in my second REPLACE function. In Microsoft Access, I would do this with the following</p>
  
  <p>Iif(cc.contype = x, y, iif(cc.contype = y, x))</p>
  
  <p>But I am not sure how to articulate this in SQL, would it be best I do this kind of thing in the client side language?</p>
  
  <p>Many thanks.</p>
  
  <p>EDIT: Have also tried with no luck:  </p>
  
  <pre><code>       CASE WHEN SUBSTRING(cc.contype, 1, 1) = 'C'
          THEN REPLACE(cc.contype, 'C', 'Signed')
         CASE WHEN SUBSTRING(cc.contype, 1, 1) = 'E'
          THEN REPLACE(cc.contype, 'E', 'Estimate') as ContractType,
  </code></pre>