Hi all,
please see if some one can suggest a better approach for this.
i need to move 5 million rows from one table to another.
LoanID is the only clumn in Source table
Source table structure
=========-->
=============== ===============
loanID
1
1
2
2
2
3
4
=============== =============== =======
target or detination table should look like this
=============== =============== ===========
loanID Sqeuence_number _with_in_LoanID
1 1
1 2
2 1
2 2
2 3
3 1
4 1
=============== =============== ===========
this is what i have tried so far
1)there are about 4 & 1/2 million out of 5 million which will appear
only once (this is one tine load) in source table.
so if i do this
-----------
sleect loanID
from SourceTable
group by loanID
having count(*)=1
and then i will hard code Sqeuence_number _with_in_LoanID to 1 .because
i know they will only come once.this is set based operation so this is
fast.
2)now,problem is with remainder of the 1/2 million rows.
i had to use cursor for this which is very-very slow.
other option i was thinking of is to pull it in the front end
(.net)and do it there.i am hoping that will be faster.
Database i am working on is sql server 2000.
if some could suggest me some better approach of handling this
remainder
1/2 milion rows.
thanks in advance
-sidd
please see if some one can suggest a better approach for this.
i need to move 5 million rows from one table to another.
LoanID is the only clumn in Source table
Source table structure
=========-->
=============== ===============
loanID
1
1
2
2
2
3
4
=============== =============== =======
target or detination table should look like this
=============== =============== ===========
loanID Sqeuence_number _with_in_LoanID
1 1
1 2
2 1
2 2
2 3
3 1
4 1
=============== =============== ===========
this is what i have tried so far
1)there are about 4 & 1/2 million out of 5 million which will appear
only once (this is one tine load) in source table.
so if i do this
-----------
sleect loanID
from SourceTable
group by loanID
having count(*)=1
and then i will hard code Sqeuence_number _with_in_LoanID to 1 .because
i know they will only come once.this is set based operation so this is
fast.
2)now,problem is with remainder of the 1/2 million rows.
i had to use cursor for this which is very-very slow.
other option i was thinking of is to pull it in the front end
(.net)and do it there.i am hoping that will be faster.
Database i am working on is sql server 2000.
if some could suggest me some better approach of handling this
remainder
1/2 milion rows.
thanks in advance
-sidd
Comment