I have a source table
tim_clmHdr (claim_code varchar(20), diag varchar(6))
with 1356080 rows. claimcode repeats but not diag.
I have a target table
tbl_claimmaster(claim_code varchar(20), diag1 varchar(6), diag2 varchar(6), diag3 varchar(6), diag4 varchar(6)) with 1203607
I need to find upto 4 diagnosis codes from the source table and update them in the target table matching on the claim_code. it seems most of the claims have only one diagnosis code but i have to look in the source if it has multiple and update if they exist.
My solutions seems to be slow..i have indexed the sourcetable on those 2 columns and running a cursor (with order by claim_code) on itand updating the (Appropriate Diag )target by matching on claimcode. i have indexed the target table on claim_code so that the matching will be faster.
does anybody has a solution where in i can avoid cursors for this situation of multiple rows (single column) getting updated into a single row (multiple columns)...especially dealing with a million rows..
i Appreciate any suggestions in this regard..
~Many Thanks in advance
tim_clmHdr (claim_code varchar(20), diag varchar(6))
with 1356080 rows. claimcode repeats but not diag.
I have a target table
tbl_claimmaster(claim_code varchar(20), diag1 varchar(6), diag2 varchar(6), diag3 varchar(6), diag4 varchar(6)) with 1203607
I need to find upto 4 diagnosis codes from the source table and update them in the target table matching on the claim_code. it seems most of the claims have only one diagnosis code but i have to look in the source if it has multiple and update if they exist.
My solutions seems to be slow..i have indexed the sourcetable on those 2 columns and running a cursor (with order by claim_code) on itand updating the (Appropriate Diag )target by matching on claimcode. i have indexed the target table on claim_code so that the matching will be faster.
does anybody has a solution where in i can avoid cursors for this situation of multiple rows (single column) getting updated into a single row (multiple columns)...especially dealing with a million rows..
i Appreciate any suggestions in this regard..
~Many Thanks in advance