Exporting by Primary Number

S

scottdog129

I have a .csv file that goes over the 65K row limitation in Excel (in this
case, its 85K). I want to create two .xls files, one for 60K rows and one
for the remaining 25K rows. What can I use to select the first rows by the
primary key so that I can export to .xls?
 
K

Klatuu

Create two queries that use the TOP statement. It is important to use the
Order by or the TOP will return a random set. One query will return the
first number requested, then in the other set the Order By to ASC so you will
get the remaining records. If the number of records is variable, you may
need to construct some code to get the numbers so you wont have any gaps or
overlaps.
 
K

Klatuu

Okay. If you go into your query in design view. Click on the Properties
icon. One of the properties you wll see is Top Values. You can put a number
in there and it will return that number of records. If you put a % behing
the number, it will return that percentagel of the total number of records.

Then you will want to select a field with unique values (the table's primary
key is always good) to sort on. For the first version of the query, select
Ascending and for the second Descending. To make it easy, I would set one to
50% Ascending and the other to 50% and Descending. That way you will get
half on each export. The only problem here is that if there is an odd number
of records in your table, one record will end up in both exports, but there
is not an easy way around that (that I know of).
 

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