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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert from mulitple tables

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-01-21 : 12:35:50
Is it possible to insert data into one table from mulitple tables that may not link?

Example:

OrderLine Table (OEORDLIN), WorkOrder Table (PPORDFIL) Controlfile (PPCTLFIL)

I'm inserting into PPORDFIL. First field I'm inserting is the ord_no which would come from a PPCTLFIL.START_ORD_NO

All other fields will come from OEORDLIN.

THERE IS NO LINK BETWEEN OEORDLIN AND PPCTLFIL

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-21 : 12:39:36
so how will you decide which PPCTLFIL.START_ORD_NO value should go with which record of OEORDLIN? Or are you looking for a cartesian product of two tables into new table?
Go to Top of Page

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-01-21 : 12:48:21
Right now I'm just trying to create a SQL script that will do the update, I plan on using a trigger
to actually do the update. There is only one order entry person so I don't have to worry about multiple people trying to update the table. I did have another thought. Instead of using the PPCTLFIL, I was thinking something like max(ppordfil_sql.ord_no + 1).

But I would still have the same issue where the ppordfil_sql doesn't link to the oeordlin_sql.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-21 : 12:51:17
multiple people? i was not referring to multiple people. what i asked was you will have several records in tables OrderLine Table (OEORDLIN) & Controlfile (PPCTLFIL) out of which how you will decide which all records from both tables should be combined and inserted to third table
Go to Top of Page

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-01-21 : 14:10:20
There should only be one insert at a time.
Go to Top of Page

Vack
Aged Yak Warrior

530 Posts

Posted - 2009-01-21 : 14:10:36
Or I should say one record inserted at a time.
Go to Top of Page
   

- Advertisement -