hi experts,
Can you find my mistake?
Thanks
** This finds 6,170 duplicate records and inserts them, works fine:
INSERT INTO dbo.FLIGHT_DATA_FACT_EXACT_DUPLICATES
SELECT AIRLINE_CODE, CARRIER_CODE, FLIGHT_DATE, FLIGHT_NUMBER
FROM dbo.FLIGHT_DATA_FACT
GROUP BY AIRLINE_CODE, CARRIER_CODE, FLIGHT_DATE, FLIGHT_NUMBER
HAVING COUNT(*) > 1;
** But this code, using same columns, does not update any records **:
UPDATE b
SET FLIGHT_DATA_ID = a.FLIGHT_DATA_ID, LAST_UPDATE = a.LAST_UPDATE
from FLIGHT_DATA_FACT_EXACT_DUPLICATES b
join FLIGHT_DATA_FACT a on
b.AIRLINE_CODE = a.AIRLINE_CODE
AND b.CARRIER_CODE = a.CARRIER_CODE
AND b.FLIGHT_DATE = a.FLIGHT_DATE
AND b.FLIGHT_NUMBER = a.FLIGHT_NUMBER;
0 rows updated
What is wrong with my UPDATE statement ?
Thanks.
Can you find my mistake?
Thanks
** This finds 6,170 duplicate records and inserts them, works fine:
INSERT INTO dbo.FLIGHT_DATA_FACT_EXACT_DUPLICATES
SELECT AIRLINE_CODE, CARRIER_CODE, FLIGHT_DATE, FLIGHT_NUMBER
FROM dbo.FLIGHT_DATA_FACT
GROUP BY AIRLINE_CODE, CARRIER_CODE, FLIGHT_DATE, FLIGHT_NUMBER
HAVING COUNT(*) > 1;
** But this code, using same columns, does not update any records **:
UPDATE b
SET FLIGHT_DATA_ID = a.FLIGHT_DATA_ID, LAST_UPDATE = a.LAST_UPDATE
from FLIGHT_DATA_FACT_EXACT_DUPLICATES b
join FLIGHT_DATA_FACT a on
b.AIRLINE_CODE = a.AIRLINE_CODE
AND b.CARRIER_CODE = a.CARRIER_CODE
AND b.FLIGHT_DATE = a.FLIGHT_DATE
AND b.FLIGHT_NUMBER = a.FLIGHT_NUMBER;
0 rows updated
What is wrong with my UPDATE statement ?
Thanks.