-1

I have a stored procedure, and I want to delete rows daily for more than 30 days.

Which means, everyday a bit of data is saved (new record) in database, and the first day data will be deleted after 30 days.

Again in everyday.

DELETE ????
FROM Table1
WHERE  ????

And Table1 :

ID         INT
Name1      TinyInt
Name2      TinyInt
Name3      TinyInt
DateT      DateTime
Safa
  • 178
  • 1
  • 12
  • The question is duplicate, see https://stackoverflow.com/questions/5471080/how-to-schedule-a-job-for-sql-query-to-run-daily – M. Rezaeyan Jul 23 '17 at 12:11
  • Possible duplicate of [how to schedule a job for sql query to run daily?](https://stackoverflow.com/questions/5471080/how-to-schedule-a-job-for-sql-query-to-run-daily) – Evaldas Buinauskas Jul 23 '17 at 12:14
  • this is my question : " the first day data will be deleted after 30 days." And that not my answer . Please Read first and then answer(negative). – Safa Jul 24 '17 at 03:30
  • Please, If you do not, do not say anything. – Safa Jul 24 '17 at 06:46

1 Answers1

0

Found it.

In SQL Server Agent,

DELETE FROM table1
      WHERE DateT > dateadd(day, -30, getdate()) and DateT < dateadd(day, -29, getdate())
Safa
  • 178
  • 1
  • 12