title: Replacing characters in a string based on rows in a table sql
body: <p>I need to replace a list of characters in a string with some mapped characters.</p>
  
  <p>I have a table 'dbo.CharacterMappings' with 2 columns: 'CharacterToFilter' and 'ReplacementCharacter'.</p>
  
  <p>Say that there are 3 records in this table: </p>
  
  <pre><code>Filter   Replacement    
  $        s
  @        a
  0        o
  </code></pre>
  
  <p>How would I replace all of the filter characters in a string based on these mappings?</p>
  
  <p>i.e. 'Hell0 c@t$' needs to become 'Hello cats'.</p>
  
  <p>I cant really think of any way of doing this without resorting to a table variable and then looping through it. I.e. have a table variable with a 'count' column then use a loop to select 1 row at a time based on this column. Then I can use the REPLACE function to update the characters one at a time.</p>
  
  <p>Edit: I should note that I always want to strip out these characters (I don't need to worry about $5 -> s5 for example).</p>