I am not sure how to create a procedure using a cursor to create a loop where records are check to possibly be updated, deleted or inserted into multiple tables.
I have a Daily updated table (A) that is truncated and recreate every day with the lastest data. I have a parts pricing table (B) that contains a vehicle Identification number with every pricing record. The vehicle identification number (VIN) is not unique in this table as a VIN can have multiple records in this table. I have another table where the VIN is unique in the table. This table contains various information about the Vehicle and other attributes (table C) .
So the relationship between table C and table B is one to many. (only one record in C may return multiple rows in B).
If a record exists in A but does not exist in B then:
I need to update the record(s) in B and the record in C.
If a record exists in A and exists in B then
update the record(s) in B and update the record in C
If record does not exist in A then
delete the record from B and C.
I hope this makes sense. Please let me know if you need more details!!