TEMP TABLE TO REAL TABLE
I have some values in a temp table called tblMedia_Master that I want to export to the real table called tblMedia.
These are the rules:
1 - If the VehicleKey (Key) is in both tables then I do an update
2 - If the VehicleKey (Key) is in the temp table(tblMedia_Master ) but not in the Real table (tblMedia) I do an insert.
3 - If the VehicleKey (Key) is in the real table (tblMedia) but not in the temp table(tblMedia_Master ) I need to to a delete.
I am not sure how to add delete statement to my SQL below to achieve item 3 above.
I would appreciate if someone could help me to complete the SQL query below so that I can delete the rows from tblMedia that are not present in the temp table tblMedia_Master
VehicleKey = tblMedia_Master.VehicleKey,
[MediaName] = tblMedia_Master.mediaName,
Specialty = tblMedia_Master.Specialty,
FormatType = tblMedia_Master.FormatType,
INNER JOIN tblMedia
ON tblMedia.VehicleKey = tblMedia_Master.VehicleKey
INSERT INTO tblMedia(
WHERE VehicleKey NOT IN (
SELECT VehicleKey FROM tblMedia