Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.79 KB | None | 0 0
  1. declare @support_id bigint --Variable de parcours pour les support_id
  2. declare @vehicle_id_table table (support_id bigint) --Table pour le parcour des support_id
  3. declare @delete_vehicle_support_id table (support_id bigint) --Table des delete à faire
  4.  
  5. insert into @vehicle_id_table
  6. select support_id
  7. from vehicle_support
  8. group by support_id, vehicle_id
  9. having count(support_id)>1
  10.  
  11. while (select count(*) from @vehicle_id_table) >0
  12.     begin
  13.     set @support_id = (select top 1 support_id from @vehicle_id_table)
  14.     delete from @vehicle_id_table where support_id = @support_id
  15.     insert into @delete_vehicle_support_id select MIN(id) from vehicle_support where support_id=@support_id -- A la place de ce selecte le DELETE SA MAMAN
  16. end
  17.  
  18. select * from @vehicle_id_table
  19. select * from @delete_vehicle_support_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement