Updates sql to remove duplicates avoiding auto-deletion