I have been looking into questions with duplicate rows, but haven't seen anything that matches my case. Furthermore, I am fairly new to SQL Server so I apologize if I don't make much sense.
So I have an existing table (lets say TableA) that holds historical information. I have a query that runs every Sunday and creates a table, only with input from the previous week (Saturday to Friday) and stores it in another table (TableB).
I am updating TableA with data from TableB every Sunday and I am using INSERT INTO, which works. However sometimes I might have to run the query manually mid-week in which case I might get duplicates on Sunday.
How exactly do I write the INSERT INTO so I don't get duplicate rows and keep the values from the latest execution query?