I need your help in figuring out how to merge two tables -
1) Both table columns are identical.
2) First table is the master production table
3) Second table is the temp table that sucks data from various feeds nightly.
What I want to do -
1) Lookup if row is already there in master table (determined by product SKU - already indexed),
1 a) If there, update data e.g. availability column, price column.
1 b) If not there, insert record into master table.
2) If record is not in temp table and is there is master table, mark the status column as 'inactive'
I have written a program that loops over each row of temp table and does the above, problem is that it takes 1 hr every 10,000 rows and I have ~ 1Million.
Is there a more efficient way to do this?