Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. DECLARE @max_id INT = (SELECT MAX(ID) FROM your_table),
  2. @checpoint INT = 500000,
  3. @current_id INT = 0,
  4. @step INT = 0;
  5. WHILE (@current_id < @max_id)
  6. BEGIN
  7. INSERT INTO #tmp
  8. SELECT *
  9. FROM your_table
  10. WHERE id > @current_id and id < @current_id + @step * @checkpoint;
  11. -- your analysis here
  12. SET @step += 1;
  13. SET @current_id = @current_id + @step * @checkpoint
  14. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement