I need to clear couple of tables every night on my db so in the morning they will be empty and ready to use for the end users.

I already wrote the query to truncate them but I'm not sure what is the best way to run it scheduled every midnight.

What is the best way to schedule such a task on windows server ?

  • 3
    you could use the Windows Task Scheduler. windows.microsoft.com/en-us/windows/schedule-task#1TC=windows-7
    – Hannah Vernon
    Jun 4, 2015 at 21:42
  • 1
    If you want to empty the tables, you may want to use TRUNCATE instead.
    – dezso
    Jun 4, 2015 at 22:02
  • is it better using the scheduler over something like pgAdmin ?
    – Alophind
    Jun 4, 2015 at 22:17
  • @dezso - I've edited my question to use truncate.
    – Alophind
    Jun 4, 2015 at 22:18
  • 3
    I prefer to use the task scheduler. PgAdmin's PgAgent is largely unnecessary, and I find task scheduler both more flexible and easier. Just invoke a psql job. Jun 4, 2015 at 23:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.