Is there any option like "Time to live" in SQL Server?

Viewed 6982

Is there any option like "Time to live" in SQL Server?

Recently I learned about Time to Live in Scylla DB. I would like to know is the option same available across the databases especially SQL Server.

I have searched in Internet but I couldn't get for SQL Server.

2 Answers

There is no direct equivalent in SQL Server. However, there's nothing stopping you doing this:

  • Add an ExpiryDateTime column to the table
  • Add a trigger that sets the ExpiryDateTime to whatever future time you think is appropriate. Make the triger fire on INSERT and UPDATE
  • Add a Agent job that periodically deletes rows that have expired

It'll end up pretty much the same as what is there with Scylla DB's TTL.

I take a simplistic attitude towards this. Since we don't have TTL in Microsoft SQL Server we could create TTD triggers. In other words TTD TIME TO DIE when an event happens it checks and kills everything that needs to be killed.

Related