• The calculation of the column

    ISNULL(S.RandomNumber, 0) - ISNULL(D.RandomNumber, 0) AS RandomNumberDiff

    requires some attention. It is important to choose a numeric value that is far from your threshold number or it will yeild incorrect results. For example if the RandomNumber value in one set is 0 and the key is missing in the other then the difference will calculate as 0, even though they actually are not equal. If no good dummy value is apparent then logic like the following is needed:

    SELECT COALESCE(S.ID, D.ID) AS ID,

    S.RandomNumber AS SrcRandomNumber,

    D.RandomNumber AS DestRandomNumber,

    S.RandomNumber - D.RandomNumber AS RandomNumberDiff

    FROM SRC S

    FULL JOIN DEST D ON S.ID = D.ID

    WHERE ABS(S.RandomNumber - D.RandomNumber) > @Tolerance

    or (S.RandomNumber is null and D.RandomNumber is not null)

    or (S.RandomNumber is not null and D.RandomNumber is null);