Hi All,
I am using a merge query to do an update(Please find the query below,
There are around 30 columns in each table but i have just provided three here)
There are about 30 million records in the source table and 300,000 records in the destination table.
There is a index in the joining column in both table.
However this query takes forever to complete.Please provide suggestions.
MERGE DestTable AS Dest
USING
( SELECT Col1 ,
Col2 ,
Col3 ,
CHECKSUM(Col1, Col2, Col3) AS [CheckSUM]
FROM SourceTable
) AS SRC
ON SRC.Col1 = Dest.Col1
WHEN MATCHED and SRC.[CheckSum] <> Dest.[CheckSum]
THEN
UPDATE SET
Dest.Col2 = SRC.Col2 ,
Dest.Col3 = SRC.Col3 ,
Dest.CheckSum = SRC.Checksum;
↧