MasterRacker
New member
I'm trying to fix an ad-hoc database that's completely flat. I have a single table with this column structure:
Item, Category, Supplier, 01Date, 01Supplier, 01Invoice, 01QuantityIn, 01UnitCost, 01Department, 01QuantyityOut, 02Date, 02Supplier, 02Invoice, 02QuantityIn, 02UnitCost, 02Department, 02QuantyityOut, ... on out to 48xxx <runs screaming...>
The numbered groups represent inventory transactions. I've created an actual database with tables for Products, Suppliers, Categories, Transactions, etc.
I'm having trouble wrapping my mind around how to query the existing data into the new system. I can do SELECT DISTINCT to get Products, Categories, etc. My problem is how do I flatten the transactions.
The only thing I can thing of is
I would then have to keep modifying the numbers on the fields and re-running the query. There has to be a better way.
Keep in mind I know I need to do more work to get to ID's etc. The above is just illustrative.
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
Item, Category, Supplier, 01Date, 01Supplier, 01Invoice, 01QuantityIn, 01UnitCost, 01Department, 01QuantyityOut, 02Date, 02Supplier, 02Invoice, 02QuantityIn, 02UnitCost, 02Department, 02QuantyityOut, ... on out to 48xxx <runs screaming...>
The numbered groups represent inventory transactions. I've created an actual database with tables for Products, Suppliers, Categories, Transactions, etc.
I'm having trouble wrapping my mind around how to query the existing data into the new system. I can do SELECT DISTINCT to get Products, Categories, etc. My problem is how do I flatten the transactions.
The only thing I can thing of is
Code:
INSERT INTO Dest.Transactions (Product, Supplier, Invoice, Date, Dept, UnitsRecd, UnitsDisbursed...)
VALUES
Src.Product, Src.01Supplier, Src.01Invoice, Src.01Date, Src.01Dept, Src.01QuantityIn....
Keep in mind I know I need to do more work to get to ID's etc. The above is just illustrative.
Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]