Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare @support_id_parcours bigint --Variable de parcours pour les support_id
- declare @support_id_table table (support_id bigint) --Table pour le parcour des support_id
- declare @delete_vehicle_support_id_to_delete table (id bigint) --Table des delete à faire
- declare @delete_contributor_support_id_to_delete table (id bigint) --Table des delete à faire
- --Selection des vehicule_support à supprimer-------------------------------------
- insert into @support_id_table
- select support_id
- from vehicle_support
- group by support_id, vehicle_id
- having count(support_id)>1
- while (select count(*) from @support_id_table) >0
- begin
- set @support_id_parcours = (select top 1 support_id from @support_id_table)
- delete from @support_id_table where support_id = @support_id_parcours
- insert into @delete_vehicle_support_id_to_delete select MIN(id) from vehicle_support where support_id=@support_id_parcours
- end
- --Selection des vehicule_support à supprimer--------------------------------------
- insert into @support_id_table
- select support_id
- from contributor_support
- group by support_id, contributor_id
- having count(support_id)>1
- while (select count(*) from @support_id_table) >0
- begin
- set @support_id_parcours = (select top 1 support_id from @support_id_table)
- delete from @support_id_table where support_id = @support_id_parcours
- insert into @delete_contributor_support_id_to_delete select MIN(id) from vehicle_support where support_id=@support_id_parcours -- A la place de ce selecte le DELETE SA MAMAN
- end
- --Suppression des doublons
- select * from @delete_vehicle_support_id_to_delete
- select * from @delete_contributor_support_id_to_delete
- --delete from vehicle_support where id in (select id from @delete_vehicle_support_id_to_delete)
- --delete from contributor_support where id in (select id from @delete_contributor_support_id_to_delete)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement