Click here to Skip to main content
15,920,111 members
Home / Discussions / Database
   

Database

 
QuestionSQL query to read all the records one by one Pin
Yvon Bourgouin9-Jun-10 3:13
Yvon Bourgouin9-Jun-10 3:13 
AnswerRe: SQL query to read all the records one by one Pin
R. Giskard Reventlov9-Jun-10 3:31
R. Giskard Reventlov9-Jun-10 3:31 
GeneralRe: SQL query to read all the records one by one Pin
Yvon Bourgouin9-Jun-10 3:53
Yvon Bourgouin9-Jun-10 3:53 
GeneralRe: SQL query to read all the records one by one Pin
R. Giskard Reventlov9-Jun-10 4:45
R. Giskard Reventlov9-Jun-10 4:45 
AnswerRe: SQL query to read all the records one by one Pin
Scubapro9-Jun-10 4:50
Scubapro9-Jun-10 4:50 
GeneralRe: SQL query to read all the records one by one Pin
Yvon Bourgouin9-Jun-10 4:58
Yvon Bourgouin9-Jun-10 4:58 
GeneralRe: SQL query to read all the records one by one Pin
Johan Hakkesteegt10-Jun-10 3:09
Johan Hakkesteegt10-Jun-10 3:09 
GeneralRe: SQL query to read all the records one by one Pin
supercat99-Jun-10 5:43
supercat99-Jun-10 5:43 
That is going to be really slow, since retrieving e.g. records 4801-5000 will use 5,000 records' worth of processing to retrieve 200 records; retrieving records 49,801-50,000 will use 50,000 records' worth of processing to retrieve 200 records. To get through 1,000,000 records would require processing about 2,500,000,000.

To add insult to injury, deleting records from the table may cause some records (not involved in the deletion) to be skipped. Adding records may cause some records to be duplicated, but that's a far smaller problem.

If the value in column IJK uniquely identifies records, use "SELECT TOP 200 ... WHERE [IJK] > @lastijk" where parameter @lastijk is the last value you retrieved. I'd guess that IJK is probably unique, since if it isn't your code won't work properly at any speed, but if it is not unique, use "SELECT TOP 200 ... WHERE [IJK] > @lastijk" followed by "SELECT ... WHERE [IJK] = @lastijk" (no TOP 200 qualifier there, and use the last record from the first query for @lastijk); all of the records where IJK equals @lastijk will appear in the second query, so you should ignore any items from the first query where IJK equals @lastijk.

Incidentally, to get reasonable performance, you'll need to have an index--preferably clustered--on @lastijk. I'd guess you probably do have one, or else your performance would be really slow for even the first 200 records.
GeneralRe: SQL query to read all the records one by one Pin
Yvon Bourgouin9-Jun-10 8:55
Yvon Bourgouin9-Jun-10 8:55 
GeneralRe: SQL query to read all the records one by one Pin
David Skelly9-Jun-10 5:44
David Skelly9-Jun-10 5:44 
GeneralRe: SQL query to read all the records one by one Pin
i.j.russell9-Jun-10 8:20
i.j.russell9-Jun-10 8:20 
GeneralRe: SQL query to read all the records one by one Pin
Yvon Bourgouin9-Jun-10 8:53
Yvon Bourgouin9-Jun-10 8:53 
AnswerRe: SQL query to read all the records one by one Pin
J4amieC9-Jun-10 4:54
J4amieC9-Jun-10 4:54 
QuestionMS SQL permissions mangement Pin
T M Gray8-Jun-10 10:21
T M Gray8-Jun-10 10:21 
AnswerRe: MS SQL permissions mangement Pin
Mycroft Holmes8-Jun-10 15:07
professionalMycroft Holmes8-Jun-10 15:07 
GeneralRe: MS SQL permissions mangement Pin
T M Gray9-Jun-10 8:06
T M Gray9-Jun-10 8:06 
GeneralRe: MS SQL permissions mangement Pin
Mycroft Holmes9-Jun-10 12:52
professionalMycroft Holmes9-Jun-10 12:52 
QuestionDatabase Size Pin
It_tech8-Jun-10 5:38
It_tech8-Jun-10 5:38 
AnswerRe: Database Size Pin
Mycroft Holmes8-Jun-10 15:02
professionalMycroft Holmes8-Jun-10 15:02 
GeneralRe: Database Size Pin
It_tech8-Jun-10 21:26
It_tech8-Jun-10 21:26 
GeneralRe: Database Size Pin
Mycroft Holmes8-Jun-10 22:35
professionalMycroft Holmes8-Jun-10 22:35 
Questionunresolved external symbol sqlcxt Pin
ravi1204868-Jun-10 1:02
ravi1204868-Jun-10 1:02 
AnswerRe: unresolved external symbol sqlcxt Pin
Chris Meech8-Jun-10 7:14
Chris Meech8-Jun-10 7:14 
QuestionTriggers Pin
Morgs Morgan7-Jun-10 3:28
Morgs Morgan7-Jun-10 3:28 
AnswerRe: Triggers Pin
Mycroft Holmes7-Jun-10 4:33
professionalMycroft Holmes7-Jun-10 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.