views:

15

answers:

1

Hi, I'm trying to figure out how to develop the on my database. E.g. there are some records in the database:

alt text

So, if the actual DateTime on the server is 2010-01-09 12:12:12 the record no.1 must be deleted.

OK, but what, if in the datebase are e.g. 1.000.000 records? The server has to search in the database on each second to check what rows must be deleted ? It's not efficient at all.

I'm totally new to Microsoft Server so I'd be grateful of any kind of help

+1  A: 

There isn't a time based trigger in sql server. So you are going to have to implement this as a job or through some other scheduled mechanism.

Most likely you will want an index on the StartDate (end date?) column so that your deletion query doesn't have to perform a full table scan to find the data it needs to delete.


Usually you don't actually perform deletes every second. Instead the app should be smart enough to query the table in a way to eliminate those records from it's result set. Then, you can perform lazy deletes at some other time interval to do cleanup. Such as once an hour or once a day etc.

Chris Lively