• happycat59 (2/10/2014)


    Rather than dropping/renaming tables, how about using the ALTER TABLE...SWITCH command. It will not leave you with any period when the table doesn't exist (SQL manages that for you) and it is one command so there is less chance of something going wrong.

    This will only work if you truncate the table or delete all its rows before switching the new table into it, since ALTER TABLE new_table TO old_tableonly works if old_table is empty. So it isn't a single command instead of two, it is still two commands.

    Another way (slightly more complicated, because you eventually need a drop statement anyway to tidy up) is to use two rename statements instead of a drop and a rename - this means you can keep the old contents until you are sure you won't need them, and rename back again if you do need them.

    Tom