Return query records in groups of 500

D

dkimbrell

I have a query with varying quantities of records in it, say anywhere
from 20-10000 depending on the filter criteria.

I need to export these records in groups of 500. I suppose opening
multiple queries, each with 500 records, is the way to do this.

I know I can use SELECT TOP 500 to return the first group, but how do
I get the subsequent groups, like 501-1000?
 
J

John W. Vinson

I have a query with varying quantities of records in it, say anywhere
from 20-10000 depending on the filter criteria.

I need to export these records in groups of 500. I suppose opening
multiple queries, each with 500 records, is the way to do this.

I know I can use SELECT TOP 500 to return the first group, but how do
I get the subsequent groups, like 501-1000?

A (probably inefficient) subquery:

SELECT TOP 500 <whatever>
FORM <wherever>
WHERE primarykey NOT IN (SELECT TOP 1000 X.primarykey FROM tablename AS X
ORDER BY sortterm)
ORDER BY sortterm;

would get the 1001st throgh 1500th records.

I'll have to think if there's some good way to automate this.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

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