title: Most efficient way to periodically copy an entire SQL database table to another [history] table
body: <p>I want to periodically copy the entire contents of a table to a second history table, which is identical, except for an extra datetime column. The 'live' table can have up to 100,000 rows, which need copying over every hour, or maybe less.</p>
  
  <pre><code>using (var db = new MyProjectEntities())
  {
      var newData = from d in db.Data select d;
      foreach (var d in newData)
      {
          var histData = new DataHistory
          {
              DataName = d.DataName,
              DataType = d.DataType,
              DataValue = d.DataValue,
              Id = d.Id,
              SnapshotDate = DateTime.Now
          };
          db.DataHistories.Add(histData);
      }
      db.SaveChanges();
  }
  </code></pre>
  
  <p>Is this really the best and most efficient way to do this? The history table is for data mining and producing graphs of data changes over time ranges, etc.</p>