Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use a select statement to return the first 250,000 records

Status
Not open for further replies.

tmartin99

MIS
Joined
Sep 14, 2001
Messages
9
Location
US
Does anyone know how to use just a select statement to
1. return the first 250,000 records from a table, then
2. return the next 250,000 records from a table.
on subsequent runs of the sql script?
 
select top 100 * from table

Selects the top 100.

If you say:

select top 100 * from table order by id

You'd get the first 100, then say:

select top 100 * from table where id > 100 order by id

You'd get the next 100, assuming all your ids are present.
Of course you'd really want to get the max value from the first select and use that in your where clause.

my 2 cents :-)

mingus
 
Does SQL Server not have rowid's like Oracle?

in Oracle you can say:

select rowid from dual;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top