Question : Question regarding varchar index and limit in MySQL and MS SQL

Hi,

I am reading a varchar field (call it vfield) from MySQL into MS SQL using openquery function.  The mysql field is type varchar and is the primary key.  There are 2 million of these mysql rows that I would need to read into mssql environment.  Trouble is odbc can't handle the entire read in 1 transaction so I would have to do this piecemeal, maybe about 100k rows at a time.  Trouble is how do I keep track of the maximum of vfield during each read so that i can go and fetch the next 100k rows on the next read, and so on until the entire table is read?

Is there a syntax that can give me the vfield on 100k row so i can keep track of this value for next read?  I couldn't figure out how to do this w/ the limit clause.  Maybe MySQL has another fcn for this?  Thx.

Answer : Question regarding varchar index and limit in MySQL and MS SQL

the LIMIT is the way to go:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
first read: 
SELECT * 
FROM yourtable 
ORDER BY vField
LIMIT 0,10000 
second read: 
first read: 
SELECT * 
FROM yourtable 
ORDER BY vField
LIMIT 10000,10000 

third read: 
SELECT * 
FROM yourtable 
ORDER BY vField
LIMIT 20000,10000 
etc.
Open in New Window Select All
Random Solutions  
 
programming4us programming4us