Hi,
I want to create trigger in SQL server that removes record which are older than one week.
I have date field in table, after inserting record in this table, it should automatically removed from table after one week. I want trigger to create trigger for that.
So help me how to create such trigger that fires after some time interval.
Thanks.
Loading
Jignesh TrivediPosted Apr 4, 2013, 12:25 AM
hi,
Agree with Javeed,
you may use SQL JOB. this SQL job is not available in SQL express edition.
if you are SQL express edition use the you can create console application and this application is run by windows Scheduler.
please refer for SQL Job
http://msdn.microsoft.com/en-in/library/ms191439%28v=sql.100%29.aspx
http://windows.microsoft.com/en-in/windows7/schedule-a-task
hope this will help you.
Javeed M ShaikhPosted Apr 3, 2013, 5:06 PM
Instead of a trigger which will fire on every event, I would suggest you create a job which will run against this table and delete data which is older than a week. You can have this job run everyday during a quite time.