I have 2 tables named BM_Data1
& BM_Data1_May62019
. Both Tables contains the same data as BM_Data1_May62019
is the copy of BM_Data1
table. But BM_Data1
has some extra rows, How can I delete those extra rows from BM_Data1
and make it same like BM_Data1_May62019
.
I got the extra rows using the following query.
SELECT * FROM (SELECT * FROM BM_DATA1 EXCEPT SELECT * FROM BM_DATA1_MAY62019) a
There are 7803 extra rows, how can I delete them from BM_Data1
table?
Thank You
Advertisement
Answer
As you confirmed RECID is common in both table with unique value, you can try this following script
DELETE FROM BM_DATA1 WHERE RECID NOT IN ( SELECT RECID FROM BM_DATA1_MAY62019 )