title: How to insert records to SQL with looked up values?
body: <p><strong>Scenario</strong></p>
  
  <p>I need to update a SQL 2008 database daily via a spreadsheet (the only option available). The format is pretty basic, however there are potentially millions of records. Column1 and Column3 will have many predefined duplicate values, already pulled out into separate tables.</p>
  
  <p><strong>Spreadsheet Sample</strong>   </p>
  
  <pre><code>Column1 Column2 Column3
  Apple   10      Red
  Apple   20      Red
  Apple   15      Blue
  Apple   21      Green
  Orange  10      Orange
  Orange  7       Orange
  Orange  9       Red
  Orange  70      Blue
  Orange  10      Blue
  </code></pre>
  
  <p><strong>DB Setup</strong></p>
  
  <p>My database is set up with three separate tables:</p>
  
  <pre><code>//Lookup_Column1
  id type
  1  Apple
  2  Orange
  
  //Lookup_Column3
  id type
  1  Red
  2  Blue
  3  Green
  4  Orange
  
  //Main - this is what should be inserted, after Column1
  //and Column2 are matched to their respective ID's
  key Column1 Column2 Column3
  1   1       10      1
  2   1       20      1
  3   1       15      2
  4   1       21      3
  5   2       10      4
  6   2       7       4
  7   2       9       1
  8   2       70      2
  9   2       10      2
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How can I write the SQL to insert records that match the information from the lookup tables? How can I go from this:</p>
  
  <pre><code>INSERT INTO Main(Column1, Column2) VALUES ('Apple', 10, 'Red');
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>INSERT INTO Main(Column1, Column2) VALUES (1, 10, 1);
  //pulled from lookup tables, where Apple = 1 and Red = 1
  </code></pre>