MSSQL record date/time auto delete

后端 未结 2 758
执念已碎
执念已碎 2020-12-03 11:45

I want to delete records from a db table based on a time-stamp for each record. I would like to have it automatically delete records compared to a date/time interval without

相关标签:
2条回答
  • 2020-12-03 12:00

    SQL Server Agent can do this for you.

    Simply create a job with a regular schedule and the SQL you want to run. There is an easy to use wizard interface for job creation.

    0 讨论(0)
  • 2020-12-03 12:03

    Create a sql JOB with below query:

    UPDATE [dbo].[User] WITH (ROWLOCK) SET active_flag=0 where lastlogindt < DATEADD(Day,-90,GETDATE())

    0 讨论(0)
提交回复
热议问题