Run Query - return 10 rows

A

Andy

Is there anyway in which I can run a select query, but only return say the
first ten rows to save time? Running a query against a million records takes
some time and whilst making ammendments I quickly want to review some of the
returned formats (say the first ten).
Ta
 
J

Jerry Whittle

Change the SQL statement from:

SELECT ......
to
SELELCT TOP 10 .....

For the TOP statement to work you need to have a sort field or ORDER BY
clause.

HOWEVER, it still needs to search through all the records. An index on the
sorted field(s) can help. Better yet would by criteria or a WHERE clause to
limit the records. For example if there is a date/time field in the table,
you might want something like the following in the criteria/WHERE clause to
pull the records from the last few days:
Date() - 10

Make sure that the field with criteria is also indexed to speed things up.

Now if the million records are in something like SQL Server or Oracle
instead of Access, you can get much better performance with a pass-through
query.
 

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