Deleteing Old Data Automatically

  • How would I setup a T-SQL statement that would automatically delete data that is 18 months (or older)? I can do it by manually coding a date in my delete statement but I'd like to have it automated.

    Any advice is appreciated.

    Thanks,

    Brian

  • Delete from dbo.YourTable where DateCol < DateAdd(m, -18, getdate())

    You can then run this in a job whenever you need (just schedule de job to run whenever necessary).

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply