UPDATE LG_002_CLCARD SET

LG_002_CLCARD.CODE = (SELECT TOP 1 CODE FROM LG_001_CLCARD WHERE LG_001_CLCARD.DEFINITION_=LG_002_CLCARD.DEFINITION_ )

SELECT LG_001_CLCARD.LOGICALREF, LG_001_CLCARD.DEFINITION_ ,LG_002_CLCARD.DEFINITION_ ,LG_002_CLCARD.LOGICALREF
FROM LG_001_CLCARD INNER JOIN LG_002_CLCARD ON LG_001_CLCARD.DEFINITION_ =LG_002_CLCARD.DEFINITION_

SELECT DEFINITION_ ,COUNT() FROM LG_001_CLCARD GROUP BY DEFINITION_ HAVING COUNT() > 1

SELECT * INTO CCC FROM (SELECT DEFINITION_ FROM LG_002_CLCARD GROUP BY DEFINITION_ HAVING COUNT() > 1)
SELECT DEFINITION_ FROM LG_002_CLCARD GROUP BY DEFINITION_ HAVING COUNT(
) > 1

UPDATE LG_002_CLCARD SET CYPHCODE=1 WHERE LG_002_CLCARD.DEFINITION_ = (SELECT DEFINITION_ FROM LG_002_CLCARD GROUP BY DEFINITION_ HAVING COUNT(*) > 1 )