title: SQL Nested Replace
body: <p>I have a complex nested replace which I am using to join two tables in MSSQL.</p>
  
  <pre><code>select * from A
    left outer join 
  select * from B
  on
    replace(
       replace(
          replace(
             replace(
                replace(A.Column1, '1114', ''),
               '1160', ''), 
            '1162', ''),
          '1167', ''),
        '1176', ''),
      '1177', '')  = B.Column1
  </code></pre>
  
  <p>The whole reason I am doing this is because data in Table1 contains of some <em>noise</em> - numbers like <em>1160</em>, <em>1162</em> etc wheres Table2 is clean characters.</p>
  
  <pre><code>Eg. - Table 1 - 'HELLO1160WORLD'
        Table 2 - 'HELLOWORLD'
  </code></pre>
  
  <p>Now in my situation I should be able to <strong>match</strong> them as one entry.</p>
  
  <p>My current approach of nested replace does work but I am not convinced that this is an elegant way to do this. Any help will be much appreciated. Thanks</p>