|
dba123
Yak Posting Veteran
90 Posts |
Posted - 2005-12-15 : 22:25:13
|
| I need to essentially do 2 loops. One loops through each record and then inside each record row, I want to perform an insert on each column.Something like this maybe using a cursor or something else:For each record in my table (I'll just use the cursor) For each column in current record for cursor perform some sql based on the current column value NextNextSo below, all I need to do is figure out how to loop through each column for the current record in the cursorASDECLARE Create_Final_Table CURSOR FORSELECT FieldName, AcctNumber, Screen, CaseNumber, BKYChapter, FileDate, DispositionCode, BKUDA1, RMSADD2, RMSCHPNAME_1, RMSADDR_1, RMSCITY_1, RMSSTATECD_1, RMSZIPCODE_1, RMSWORKKPHN, BKYMEETDTE, RMSCMPNAME_2, RMSADDR1_2, RMSCITY_2, RMSSTATECD_2, RMSZIPCODE_2, RMSHOMEPHN, BARDATE, RMSCMPNAME_3, RMSADD1_2, RMSADD2_3, RMSCITY_3, RMSZIPCODE_3, RMSWORKPHN_2FROM EBN_TEMP1OPEN Create_Final_TableFETCH FROM Create_Final_EBN_Table INTO @FieldName, @AcctNumber, @Screen, @CaseNumber, @BKYChapter, @FileDate, @DispositionCode, @BKUDA1, @RMSADD2, @RMSCHPNAME_1, @RMSADDR_1, @RMSCITY_1, @RMSSTATECD_1, @RMSZIPCODE_1, @RMSWORKKPHN, @BKYMEETDTE, @RMSCMPNAME_2, @RMSADDR1_2, @RMSCITY_2, @RMSSTATECD_2, @RMSZIPCODE_2, @RMSHOMEPHN, @BARDATE, @RMSCMPNAME_3, @RMSADD1_2, @RMSADD2_3, @RMSCITY_3, @RMSZIPCODE_3, @RMSWORKPHN_2WHILE @@FETCH_STATUS = 0BEGIN @Chapter = chapter for this record For each column in current record <---- not sure how to code this part is what I'm referring to do some stuff here using sql for the column I'm on for this row Next Case @Chapter Case 7 Insert RecoverCodeRecord Insert Status Code Record Insert Attorney Code Record Case 13 Insert Record Insert Record Insert Record Case 11 Insert Record Insert Record Insert Record Case 12 Insert Record Insert Record Insert RecordENDclose Create_Final_Tabledeallocate Create_Final_Table |
|