Is there a way to limit the number of rows in a SQL Server 2000 database, such that older rows are deleted when new ones come in?
I have some data that I’d like to keep around for a about thirty days – after that, I don’t care whether the data lays around or is deleted – as long as the table doesn’t become huge.
Any other suggestions or welcome – I’m decent with programming against a database, but I’m by no means a DBA.
Thanks.
Not explicitly, no. However, you can set up a
TRIGGERon theINSERTfor the database to delete any rows older than thirty days (so you only delete rows as you add more, not just for the sake of it). Or, you can use SQL Server Agent and set up a Stored Procedure to do adelete from table where insertdate <= dateadd(d, -30, getdate())