title: Compare phone numbers of multiple formats in SQL Server
body: <p>I want to begin by saying that this question <a href="https://stackoverflow.com/questions/15655813/comparing-phone-numbers-sql">here</a> sort of helps but my issues is a bit different.</p>
  
  <p>I have two tables. The first one has:</p>
  
  <pre><code>| AREACODE| PHONENUMBER |  Company Name   |
  ===========================================
  |   800   |   115-4454  | Sample Company  | 
  |   800   |   141-2254  | Sample Company2 |
  |   800   |   113-9857  | Sample Company3 |
  </code></pre>
  
  <p>The second table has:</p>
  
  <pre><code>|PHONENUMBER|
  =============
  |18001154454|
  |  7274313  |
  </code></pre>
  
  <p>This formatting in the second table makes it really hard for me as someone not great in SQL to match the items across tables. </p>
  
  <p>The difference in my question compared to the linked on is I can't alter the tables in any way. </p>
  
  <p>The full requirement is that when a area code + phone number in table 1 match with the phone number in table 2, I need to select a column called company name.</p>
  
  <p>I considered a solution using CASE WHEN to check the lengths and do complicated substring modifications but I doubt it would be the proper method. Any help would be appreciated. If I am unclear on anything please ask and I will do my best to clarify for you.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>All columns are strings.</p>
  
  <p>The expected results would be the company name of any matches between the tables for the phone number and the phone number in it's original format from the first table (area code + phonenumber)</p>
  
  <p>So from the above example I would expect</p>
  
  <pre><code>  PHONENUMBER   |  Company Name   |
  ===================================
    800-115-4454  | Sample Company  | 
  </code></pre>