SQL string to retrieve data in increments

G

Guest

I am using Office 2003 on Windows XP.

I am querying an Access table from Excel and I need a SQL string to import
the rows in a table in successive 200 record increments. So the first query
would return records 1 through 200. My program would work on these rows and
when done, the next query would return 201 thru 400; then 401 thru 600 etc.
for +/- 8000 records.

The final query would need to just return any fractional amount left over.

Can someone please post a hypothetical SQL string I can use to do this?

For example:

SELECT TOP 400 FieldName FROM TableName; <<<This works on first query...

Thanks much in advance.
 
J

ja

I am using Office 2003 on Windows XP.

I am querying an Access table from Excel and I need a SQL string to import
the rows in a table in successive 200 record increments. So the first query
would return records 1 through 200. My program would work on these rows and
when done, the next query would return 201 thru 400; then 401 thru 600 etc.
for +/- 8000 records.

The final query would need to just return any fractional amount left over.

Can someone please post a hypothetical SQL string I can use to do this?

For example:

SELECT TOP 400 FieldName FROM TableName; <<<This works on first query...

Thanks much in advance.


You mentioned sql. Here is an approach using ms sql batch:

SELECT TOP 400 FieldName FROM TableName
go
delete top 400 * from tablename
go
SELECT TOP 400 FieldName FROM TableName
go
delete top 400 * from tablename
go
SELECT TOP 400 FieldName FROM TableName
go
delete top 400 * from tablename
go
SELECT TOP 400 FieldName FROM TableName
go
delete top 400 * from tablename
go

etc.

repeat the select and delete query approximately 20 times if you're
querying 400 records at a time.

ja
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top