Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlbug
Posting Yak Master
201 Posts |
Posted - 2009-08-05 : 18:33:50
|
| I have the following tables:Table 1(Source) - SAMPLE_DATA: [SAMPLE_NUM],[SAMPLE_TYPE],[SAMPLE_SITE],[SAMPLE_PLOT],[SAMPLE_INTERVAL],[SAMPLE_START_DATE],[SAMPLE_START_TIME],[SAMPLE_END_DATE],[SAMPLE_END_TIME],[SAMPLE_SUBMIT_DATE]Table 2(Source) - DETAIL_DATA: – [DT_SAMPLE_NUM](FK), DT_SAMPLE_TYPE],[DT_PARAMETER],[DT_UNITS],[DT_METHOD], [DT_HOUR1_VALUE], [DT_HOUR1_FLAG],[DT_HOUR2_VALUE],……………[DT_HOUR24_VALUE],[DT_HOUR24_FLAG].Table 3(Destination) - New_Detail_Data: [DATA_ID],[DATA_SAMPLE_NUM](FK),[DATA_PARAMETER],[DATA_METHOD],[DATA_UNIT],[DATA_VALUE],[DATA_FLAG].I want to insert into the destination from the two sources like:For each Date - the foreign key values should come from the Table 1 (SAMPLE_NUM). The data values should come from the Table 2. In this source table - we have 24 data columns for 24 hours of the day. Data from 24 columns of this table will go to 24 rows of the destination table (Table 3) based on start time/end time in Table 1 (If 0000/0059, data will come from [DT_HOUR1_VALUE],[DT_HOUR1_FLAG] in Table 2 for [DATA_VALUE],[DATA_FLAG] fields in the destination...and so on). The other fields of the destination should come from the Table 2 in straight-forward manner.Really need help on this, Thanks. |
|
|
|
|
|
|
|