Hi, I have a table with C1- ID C2-Date C3-Date with time C4-quantity I need to create a daily process that will remove the oldest data(data older than 30 days) on the table and make sure the table is with only 30 days worth of data. Please help me. Thanks in advance
If you have stored insertdate in c3 column then the query should be delete yourtable where c3<dateadd(dd,-30,getdate()) This query will check recordsdate which are less than 30 days old and will delete it. Also as suggested put this query as a agent job and schedule it to run midnight.