Home › Interview Questions › A daily load needs to insert rows that are new and…

A daily load needs to insert rows that are new and update rows that already exist. How do you implement this?

🟡 Medium Conceptual Junior level
1Times asked
Sep 2026Last seen
Sep 2026First seen

💡 Model Answer

I would implement an upsert using a MERGE statement (or equivalent). First, I load the daily data into a staging table with the same schema. Then I run a MERGE that matches on the primary key: if a row exists, UPDATE the columns; if not, INSERT the new row. This ensures idempotency and avoids duplicate keys. In systems without MERGE, I can perform a LEFT JOIN between the staging and target tables, UPDATE matched rows, and INSERT the remaining rows. Using a staging table also allows me to validate data quality before merging. This approach keeps the load idempotent and efficient.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500