Database Fetching - 1000 rows at a time

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

Hi All,

I have to fetch a huge database. But I want to fetch records as follows like
:

First 1000 records
Second 1001 to 2000 records
Third 2001 to 3000 records
and so on.

How will I do this in C# and what is the SQL Syntax I should use?

Thanks for your time.

With kind regards
Anand Ganesh
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I dont remember if there is a way of doing like a server side cursor, so I
will give you a work around.

if the table has a primary key you can use a query like:

--assuming the pk is integer

select top 1000 * from table where pk > @start_value

the first time you call it with @start_value = 0 and update it accordily.

Cheers,
 
M

msnews.microsoft.com

Hi ignacio,

Thanks for the tip.

Can I use this to fetch data from all of the following databases?

1. MS Access - .mdb File
2. SQL Server
3. Oracel

Thanks
Anand Ganesh
 
G

Guest

What are you going to do with the data? Do you need to worry about the data
being changed while you have it? Are rows being updated, inserted, etc?
This would affect the approach.
 

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