You are trying to add a foreign key when no referential integrity. In table1 have code-provider couples who are not in table2 ... like the relationship is reversed?
Anyway note that when defining a multi reference key field references must be given together within the same row, so if you table2 (1, 1), (1, 2), (2, 3 ) and table 1 (1, 1), (1, 2), (1, 3) the tuple (1, 3) is not present in table2 and will not leave.
To see how many rows do not meet the integrity, you can launch a
SELECT COUNT (*) AS count FROM table1 t1 LEFT JOIN table2 t2 ON t1.codigo = t2.codigo t1.proveedor = t2.proveedor AND WHERE IS NULL t2.codigo
If not many can remove the COUNT and do you return the t1. * And so see what they are.