I need to merge three tables into one. They all have the exact same structure.
Then a target table new_TABLE_all
They were supposed to be archived over two new tables and when it happened the records in Table_A_original that were Archived were suppose to be removed. Some/many were not removed. I need to rebuild into one table now. the document_id column is the primary key and can be searched. The tables have over 100,000 million records. So I want to be as efficient as possible.
Something like this:???
insert into new_TABLE_all
Table_A_original where document_id not in (select document_id from new_TABLE_all) --- (There must be more efficient way)
then repeat for Archive1 and Archive2
Note:s document_id is an identity id and is primary key
Database is old SQL 2005, job is migrating out.