-
MelissaMa-MSFT 24,136 Reputation points
2020-10-09T01:37:25.123+00:00 Hi @David Smith ,
As mentioned by Scott, you need to have a column to determine the start position.
You could refer below two methods:
First one, add one column as ID and define it as primary key and identity(1,1). Then you could have ID as 1,2,3,...,1000000.
Try with below:
select * from Table_A where ID between 100000 and 125000 select * from Table_A order by ID offset 100000 rows fetch next 125000-100000+1 rows only
Second one, define the order of columns VAR_1, VAR_2, VAR_3. For example, VAR_1 is most important and VAR_3 is the least important.
Try with below:
select * from Table_A order by VAR_1, VAR_2, VAR_3 offset 100000 rows fetch next 125000-100000+1 rows only select * from (select Row_Number() over (order by VAR_1, VAR_2, VAR_3) as RowIndex, * from Table_A) as Sub Where Sub.RowIndex >= 100000 and Sub.RowIndex <= 125000
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Try something like this:
select *
from Table_A
order by VAR_1
offset 100000 rows
fetch next 125000-100000+1 rows only
You must specify 'order by' some column or columns.
Show the SQL version, if it does not work.