I want to insert a record into another table (ten_split) until the value exceeds a value in the End_loc field from the start_table. The idea is to split the records in the start_table into 10m segments.
start_table looks like below:
ID Start_loc End_loc
1 0 40
2 0 35
I want the ten_split table to look like below based on the start_table:
UID ID start_new end_new
1 1 0 10
2 1 10 20
3 1 20 30
4 1 30 40
5 2 0 10
6 2 10 20
7 2 20 30
8 2 30 40
I am using Microsoft T-SQL. I am new to using loops and would appreciate any help.