title: SQL Select Matches
body: <p>I have two tables, I would like to match these two tables. I tried with Excel but I did not work well because Excel sheet has more than 200.000 rows. I got answer for excel -<a href="https://stackoverflow.com/questions/4112388/lookup-serial-numbers-in-excel-through-sql-server-database">Lookup serial numbers in excel through SQL Server database</a>- 
  I am looking for an answer for matching these two tables with MSSMS.
  Regards,</p>
  
  <p>FirstTable</p>
  
  <pre><code>Material SerialNumber 
  MTR5100 1 
  MTR5100 2 
  MTR4100 3 
  MTR4100 4
  </code></pre>
  
  <p>Checktable</p>
  
  <pre><code>Material SerialNumber
  MTR5100 1 
  MTR5100 2 
  MTR6100 3 
  MTR4100 5
  </code></pre>
  
  <p><br> I would like to match FirstTable with CheckTable
  <br>*if SerialNumber exist and its Material is the same as the material name in the FirstTable, it will write "ok" to check field
  <br>*if SerialNumber exist but its Material is different from the material name in FirstTable, macro will write the material name in database refer to serial that we are looking for
  <br>*if Serial does not exist, it will write "nok" to check field</p>
  
  <p>With sql query, I would like to get this result;</p>
  
  <pre><code>Material SerialNumber Check
  MTR5100  1            ok
  MTR5100  2            ok
  MTR4100  3            MTR6100
  MTR7100  4            nok
  </code></pre>