A useful script for finding products with duplicate URLS in Magento 2.


SELECT Count(*),value
    FROM   /*PREFIX*/catalog_product_entity_varchar v
    WHERE  EXISTS (SELECT *
        FROM   /*PREFIX*/eav_attribute a
        WHERE  attribute_code = "url_key"
        AND v.attribute_id = a.attribute_id
        AND EXISTS (SELECT *
                    FROM   /*PREFIX*/eav_entity_type e WHERE 
                    entity_type_code = "catalog_product"
                    AND a.entity_type_id = e.entity_type_id
        ))
        AND store_id = /*DEF_STORE_ID*/
        GROUP  BY v.value
        HAVING Count(*) > 1


Here is a useful extension for the then de-duping on bulkĀ https://github.com/c1gee/urldedup