I am in process of writing a program in c# where I need to extract records from tables. When the table has more the 1million recordsm, my query throws OutOfMemory exception. To overcome this, I modified my query to :
string sqlQuery = "Select * from " + tname + " where ID between "+ IDStart +" and " + IDEnd;
Now the problem is every table does not have ID column, this is where my query fails.
Can you suggest me a way how to extract data (something like TOP 50000) from a table where ID column does not exist?
In short, I need to extract data in chunks.
Please let me know if you need more information.