Last post Apr 21, 2015 04:07 AM by Edwin Guru Singh
Apr 16, 2015 03:51 PM|romeo407|LINK
I am new to SQL server and am learning. I have a monthly Membership table and a DateTime field of
Expiration. What do I have to look into so that I can make my SQL Server 2012 check for expired records on a daily basis and delete them records? I know that SQL has this functionality was just wondering what is it called and do you have any
suggestions or tips on creating something like this..
Apr 16, 2015 09:49 PM|oned_gk|LINK
Usualy you can simply query the data based expiration value, no need deletion
To get data that is not expired
SELECT * FROM TABLENAME WHERE Expiration > GetDate()
If you still want to delete expired data
DELETE FROM TABLENAME WHERE Expiration < GetDate()
Apr 21, 2015 04:07 AM|Edwin Guru Singh|LINK
I have a monthly Membership table and a DateTime field of Expiration. What do I have to look into so that I can make my SQL Server 2012 check for expired records on a daily basis and delete them records?
2.In Object Explorer-->SQL, Server Agent -->Jobs-->Right Click -->New Job.
4.Steps-->New-->StepName("DeleteMember") -->Choose your Database -->Type the command
delete from tblMemberShip where expirydate<GETDATE()
5.Schedules-->New-->Name ("ScheduleName")-->Frequency(choose Daily) -->Daily frequency (Occur once at :SET specific time)
6.If you want alert & notification then set it
7.Finally click OK.
8.Then Right Click on your job name -->Click "Start job at step"