title: SQL: Normalizing Code / Export - Import
body: <p>I've decided to rewrite a database I have that is poorly normalized. I've created the new database but now need to move data from the old database into the new one. I'm not sure exactly how to accomplish though. For example, in the old database I have a webDorms table that looks like this:</p>
  
  <pre><code>id (PK, int)
  room_type (varchar) 
  description (char) 
  available (varchar) 
  max_occupancy (varchar) 
  current_occupancy (varchar) 
  dorm_room (varchar) 
  dorm_building (varchar) 
  building_code (varchar) 
  </code></pre>
  
  <p>In the new database I split this out into two tables Buildings and Housing. Housing looks like this:</p>
  
  <pre><code>id (PK, int) 
  building (FK, int) 
  room (nvarchar)
  current_occupancy (int) 
  max_occupancy (int) 
  is_available (bit) 
  gender (nvarchar) 
  room_type (nvarchar)
  </code></pre>
  
  <p>Buildings looks like this:</p>
  
  <pre><code>id (PK, int) 
  building_code (nvarchar) 
  building_name (nvarchar)
  </code></pre>
  
  <p>I've manually repopulated the Buildings table (it was around twenty rows) but the Housing table (which is most similar to the previous webDorms table) contains around three hundred rows - and I'd rather not rekey all that data.</p>
  
  <p>Any suggestions on the best way to accomplish this import?</p>