I want to create a job which deletes records from a database after a period of time has passed. For example I have a field in news table Time Stamp
and each month a SQL query runs like a scheduled job against my database and deletes news where the time stamp is two month old. Generally I want to delete news for 2 month ago and older to not let my table become a large table. How can I accomplish this?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
You will need to create a SQL Agent Job to schedule a job to periodically run. If you want to create the job with T-SQL, refer to How to: Create a SQL Server Agent Job (Transact-SQL).
you should create a job in SQL below is a sample T-SQL for create a job via SQL agent