title: SQL to bulk identify certain records and then delete from SQLServer 2008
body: <p>I have a weatherForecast table.  Every hour around 700 postcodes worth of forecasts are inserted.  These com in via three webServices.  one at .40 past, .50 past and .55 past the hour.</p>
  
  <p>This is all working fine except my code which traverses the XML and inserts it into our SQlServer 2008r2 DB has not been checking for duplicate post codes per hour.  A duplicate is defined as a post code which is in more than one of the three webServices.  So I have fixed this, My question is around how to deal with the records which have slipped through.</p>
  
  <p>E.G postCode 6330 was in the .40 and .50 mins past the hour feed therefore it has two forecasts for each hour (for a long period, the table is currently at 9 million recods).  Now this is easy for me to remove these records.  To keep the .40 mins past records and delete the .50 mins I think I can do this:</p>
  
  <pre><code>delete from Weather_Opticast_Forecast where lPostCode=6330 and datePart(minute, recordCreated) = '50'
  </code></pre>
  
  <p>Or can anyone see an issue with this.  IMO I think its safe to say the .40 mins past records will stay and the .50 mins past recs will be deleted?</p>
  
  <p>There are two postcodes we know about.  What about the ones we dont.  Do I have to write code to detect these or can SQL handle this?   I want it to say, out of the 700 records (postcodes) which insert every hour is there any records for any postCode which have been inserted within a 60 minute period?   </p>
  
  <p>Hopefully I have explained my two questions clearly.  It would be ideal to handle the identification and delete of these records with pure SQL </p>