• Another way to do this is to schedule another job to schedule an sp_stop_job. This stops the job in a far less graceful way but at the time you specify rather than the period to complete the loop.

    Your solution will always overrun by an unknown amount.

    One way to do a one-off reindex would be to create a table with all the table names/ids in and a reindexed 0,1 bit column which got updated after the reindex statement.

    This way the job would not start at the beginning again.

    For ongoing maintenance you could use a date column and select your tables on reverse date order.

    These would work with both the loop and hard kill techniques.