Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically delete records in sql server after a certain amount of time [duplicate]

I have set up temporary user accounts on my sql database where the user names, passwords and date added of my websites users are stored.

I was initially going to have these records delete programmatically but now im wondering if sql server 2008 has a built in function that allows records to be auto-deleted after lets say one day.

This would resolve the issue of a user being able to stay logged into the system after their temporary account is closed

thanks

like image 943
Master Yoda Avatar asked Aug 16 '13 14:08

Master Yoda


2 Answers

You could create a SQL Job to run each day and execute a specified stored procedure.

http://technet.microsoft.com/en-us/library/ms190268.aspx

like image 72
Darren Avatar answered Sep 27 '22 23:09

Darren


you can have your program do it, or set up a sql agent job.

like image 43
Maslow Avatar answered Sep 28 '22 01:09

Maslow