August 23, 2005 at 8:34 am
I have a table of 500,000 records and a customer wants to receive the data in seperate excel sheets of 10,000 records in each. Is there an esy way of doing this.
The table contains a unique reference and a fax number, they ideally want to have the filename for each the same as the first record in the table.
Even if i can split the data into mutiple tables i could export manually.
Thanks
August 23, 2005 at 8:40 am
I am not sure the fax number will help you, but what kind of unique reference are you using?
August 23, 2005 at 8:44 am
the unique refence is a refence generated when the record is added to the file, it is not in any particular sequence
forgot to mention they want the data sorted by fax number.
i wouldnt be a problem adding another sequenced reference number.
August 23, 2005 at 9:02 am
If it wouldn't be a problem to add another sequenced refernece number then it would be simple like
SELECT * FROM TableName WHERE NewSequence BETWEEN 0 to 10000
SELECT * FROM TableName WHERE NewSequence BETWEEN 10000 to 20000 etc
Or
create an application (Ex. VB) with server side static forward only record set and put them in different files.
Regards,
gova
August 23, 2005 at 9:04 am
Adding another sequenced number would probably make things more complex.
Given the information I have, I would think you would have to count these records as you go through the resultset and when you hit 10K, switch to a new output file. Very messy, I know, but without being able to mathmatically pull 10K records at a time, you may be forced with that solution.
August 23, 2005 at 9:06 am
Wouldn't it be a problem using those sequence numbers if output was in fax number order? What happens when new fax number is added?
August 23, 2005 at 9:10 am
there wouldnt be anymore fax numbers added to this data, this is a dataset which is final and to be given to a customer as is, they just want it delivered in files of 10,000 records rather than 500,000
August 23, 2005 at 9:14 am
Then I would use govinn's solution. I believe you would have to apply a clustered index to the fax number to order the data the way you need it when you implement the counter.
August 24, 2005 at 12:45 am
To summarize:
Create a Temp table with an autokey and the other fields you want to output. Then run : INSERT INTO TempTable SELECT Field, Field ... FROM MainTable ORDER BY FaxNo.
Now use govinn's solution to get your resultsets.
5ilverFox
Consulting DBA / Developer
South Africa
August 25, 2005 at 2:30 am
Thank you for all the replies, I have now done what I needed to do
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply