title: Update main table based on last entry into a log table on id?
body: <p>I'm not sure how to go about this. I have a relational database that information was just migrated too. Since the schema was changed from the old database, it took about 3 weeks to transfer the data properly. The old production database was still being used during that time. I have no transferred the remaining data, however this second migration just inserted new rows into the main table called tVehicleDeal and inserted the new values into the log table called tVehicleLog. My question is.. how can I update tVehicleDeal based on the last entry made into the tVehicleLog? My idea is that since the newest logs were inserted into the tVehicleLog table, then that should be the latest entry and I can use that entry to update tVehicleDeal. I know I can do something similar to this, but not sure how to get the last one for a deal.</p>
  
  <pre><code>UPDATE dbo.tVehicleDeal 
  SET InternalLocationID = l.InternalLocationID
  FROM dbo.tVehicleLog l
  WHERE l.DealID = tVehicleDeal.DealID
  </code></pre>
  
  <p>Is there a way to do this properly? Any suggestions are helpful! </p>