|
Nitu
Yak Posting Veteran
81 Posts |
Posted - 2006-05-02 : 10:38:19
|
| Hi,I need some help with tranfering data from one table to another.The structures of the table are like this,Table1: [UniqueID] [int] NOT NULL , [Yr1] [decimal](18, 6) NOT NULL , [Yr2] [decimal](18, 6) NOT NULL , [Yr3] [decimal](18, 6) NOT NULL , [Yr4] [decimal](18, 6) NOT NULL , [Yr5] [decimal](18, 6) NOT NULL , [Yr6] [decimal](18, 6) NOT NULL , [Yr7] [decimal](18, 6) NOT NULL , [Yr8] [decimal](18, 6) NOT NULL , [Yr9] [decimal](18, 6) NOT NULL , [Yr10] [decimal](18, 6) NOT NULL , [LastModified] [smalldatetime] NOT NULL Table 2: [UniqueID] [int] Not NULL , [price] [decimal](18, 6) NULL , [price_start_date] [smalldatetime] NULL , [price_stop_date] [smalldatetime] NULL , [price_replaced_date] [smalldatetime] NULL Data has to move from Table1 to Table2. In the first table yr1, yr2,.... fields have prices. The way data should be in Table2 is, 1. the table2.price_start_date is table1.lastmodified2. if the prices in all the 10 years in table1 are same then the price_stop_date should have table1.lastmodified + 10 years and the table2.price should be the price given in all the year fields.3. f prices are not same in all 10 years, then at the year where the price is different in table1, the stop_price_date should be that many years added and the table2.price should the price given in these year fields, the next record should start from the next year and should repeat until year10 is reached.Really appretiate whoever can help me on this one.Thanks a lot in advance,Nitu |
|