• Assuming the cust_id = dup_code, why not do a simple select count of all matching records between the two tables

    SELECT @Count = COUNT(t1.*)

    FROM unique_cust t1 INNER JOIN unique_cust t2 ON t1.cust_id = t2.cust_id