
DELETE FROM buchvorgaengeeigenschaften WHERE Nummer IS NULL;


CREATE TABLE tmpToDelVorgEig AS 
select  max(id) AS id, VorgangTyp, Nummer, Name, VALUE , COUNT(*) from 
buchvorgaengeeigenschaften
GROUP BY VorgangTyp, Nummer, Name, VALUE 
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC;

ALTER TABLE `tmptodelvorgeig`
	ADD INDEX `Schlüssel 1` (`id`);


SELECT COUNT(*) FROM tmpToDelVorgEig; 

DELETE FROM buchvorgaengeeigenschaften WHERE id IN (SELECT id FROM tmpToDelVorgEig); 


SELECT COUNT(*) FROM buchvorgaengeeigenschaften;

DROP TABLE tmpToDelVorgEig;


ALTER TABLE `buchvorgaengeeigenschaften`
	ADD UNIQUE INDEX `UQ` (`Nummer`, `Name`, `Value`, `VorgangTyp`);
