Guest User

Untitled

a guest
Jan 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. DECLARE @Count int
  2. DECLARE @chvCKMRefID nvarchar(50)
  3. DECLARE @intAccountID int;
  4.  
  5. DECLARE dublicate_cursor CURSOR FAST_FORWARD FOR
  6. SELECT chvCKMRefID, intAccountID, Count(*) - 1
  7. FROM Account_Professional_Information
  8. WHERE intAccountID = 194
  9. GROUP BY chvCKMRefID, intAccountID
  10. HAVING Count(*) > 1
  11.  
  12. OPEN dublicate_cursor
  13.  
  14. FETCH NEXT FROM dublicate_cursor INTO @chvCKMRefID, @intAccountID, @Count
  15.  
  16. WHILE @@FETCH_STATUS = 0
  17. BEGIN
  18.  
  19. DELETE TOP(@Count) FROM Account_Professional_Information WHERE chvCKMrefID = @chvCKMRefID AND intAccountID = @intAccountID
  20.  
  21. FETCH NEXT FROM dublicate_cursor INTO @chvCKMRefID, @intAccountID, @Count
  22. END
  23.  
  24. CLOSE dublicate_cursor
  25. DEALLOCATE dublicate_cursor
Add Comment
Please, Sign In to add comment