LucieLastic
Programmer
hi
I have a main table and a 'copy' table. The main table has a trigger on it. Each day the copy table is loaded with the new data and then it is renamed (using sp_rename) to be the main table and the main table is renamed to the copy table.
I drop all the indexes and primary keys on the tables before I call sp_Rename and then put all the indexes back on the newly renamed table.
Do I need to drop the trigger too, and then recreate that after the sp_Rename?
I tried to put it in the stored procedure which does all the dropping and renaming etc of the tables but it needed to be at the beginning of the batch and I want it at the end.
The trigger is on the UPDATE and writes changes to a log table. I do a huge update statement in the middle of the stored procedure (500000+ rows) before doing the sp_rename so it needs to be after this.
So, do I need to drop it and recreate it when using sp_rename?
And can I put it in a second stored proc and call that at the end after calling all my renaming processes/SPs?
Hope that makes sense. Many thanks for help,
lou
I have a main table and a 'copy' table. The main table has a trigger on it. Each day the copy table is loaded with the new data and then it is renamed (using sp_rename) to be the main table and the main table is renamed to the copy table.
I drop all the indexes and primary keys on the tables before I call sp_Rename and then put all the indexes back on the newly renamed table.
Do I need to drop the trigger too, and then recreate that after the sp_Rename?
I tried to put it in the stored procedure which does all the dropping and renaming etc of the tables but it needed to be at the beginning of the batch and I want it at the end.
The trigger is on the UPDATE and writes changes to a log table. I do a huge update statement in the middle of the stored procedure (500000+ rows) before doing the sp_rename so it needs to be after this.
So, do I need to drop it and recreate it when using sp_rename?
And can I put it in a second stored proc and call that at the end after calling all my renaming processes/SPs?
Hope that makes sense. Many thanks for help,
lou