DECLARE completeDataByCustomerName CURSOR LOCAL FOR
SELECT CUSTOMER_ID, REPEATED_CUSTOMER_ID, CUSTOMER_NAME FROM #SUPER_INDIVIDUAL_CUSTOMER ORDER BY CUSTOMER_ID
OPEN completeDataByCustomerName
FETCH NEXT FROM completeDataByCustomerName INTO @customerId, @repeatedCustomerId, @customerName
WHILE(@@FETCH_STATUS=0)
BEGIN
UPDATE #SUPER_INDIVIDUAL_CUSTOMER
SET REPEATED_CUSTOMER_ID = @customerId
WHERE CUSTOMER_NAME = @customerName
FETCH NEXT FROM completeDataByCustomerName INTO @customerId, @repeatedCustomerId, @customerName
END
CLOSE completeDataByCustomerName