Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Records in 2 tables from one datasource

Status
Not open for further replies.
Dec 28, 2004
87
US
I have table name (DATA SOURCE)CustInfo :

Table Name : CustInfo
Table field names :---

custId, Mon_Merchandiser, Tue_Merchandiser, Wed_Merchandiser
Thu_Merchandiser,Fri_Merchandiser,sat_Merchandiser,Sun_Merchandiser,Mon_CSR, TUE_CSR, WED_CSR, THU_CSR, FRI_CSR, SAT_CSR, SUN_CSR, MON_fullTIme, TUE_FullTime, Wed_FullTime, Thu_FullTime, FRI_FullTime, SAT_FullTime, SUN_FullTime.

Record Sample : 40003, M, NULL, NULL, NULL, M, M, NULL, C,C,C,NULL,C,NULL,C F,NULL,F,F,NULL,F,NULL,

(record sample just assume in same order for each field....another words : custID- 40003,
Mon_Merchandiser-NULL, Tue_Mechandiser- NULL ...SO ON...)



Now I have two table here where i want to insert all records from CustInfo:

Table Name : WI_Cust_With_ACT
Table Name : WI_Cust_With_Emp


I want to insert following fields in Table WI_Cust_With_ACT

CustID, Mon_Merchandise,TUE_Mechadiser,WED_Merchandise, Thu_Merchandiser, Fri_Merchandiser, Sat_Merchandiser,Sun_Merchandiser.

And I want to insert following fields in table WI_Cust_with_Emp

Mon_CSR, TUE_CSR, WED_CSR, THU_CSR, FRI_CSR, SAT_CSR, SUN_CSR, MON_fullTIme, TUE_FullTime, Wed_FullTime, Thu_FullTime, FRI_FullTime, SAT_FullTime, SUN_FullTime.

*** VERY IMPORTANT THING TABLE STRUCTURE FOR Table Name : WI_Cust_With_ACT
WI_Cust_With_Emp

Table Structure: WI_Cust_With_ACT

CustLifeNo,ActCatID, DayID

Record sample :
CustID ActCatID DayID
40003 M MON
40003 NULL TUE
40003 NULL WED
40003 NULL THU
40003 M FRI
40003 M SAT
40003 NULL SUN

Table Structure: WI_Cust_With_Emp

CustLifeNo
EmpTypeID
DayID

Record sample :
CustID EmpTypeID DayID
40003 C MON
40003 C TUE
40003 C WED
40003 NULL THU
40003 C FRI
40003 NULL SAT
40003 C SUN

AGAIN I WANT TO RUN INSERT QUERY WHICH INSERT RECORDS FROM CustInfo TO WI_Cust_With_ACT, WI_Cust_With_Emp

Thanks, for any help...

AD
 
You need to do one insert for each table.

sample insert
insert into tbl t1 (t1.fld1, t1.fld2) select t2.fld1, t2.fld2 from tbl2 t2 where xxx=yyy

Now try and build your SQL, try it, and if you still have problems post your code along with the errors you are having.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top