This will do everything:
[Code]
INSERT INTO OrderItems (
OrderID,
ItemID,
Qty,
QtyDelivered,
QtyToSend,
item_price,
item_cost,
comments,
filemaker_discount,
filemaker_price_per_item_after_discount,
import_item,
filemaker_id
)
SELECT
F.order_key,
P.id,
F.quantity_received + F.quantity_to_ship,
F.quantity_received,
F.quantity_to_ship,
F.price_per_item
F.cost,
comments,
discount,
price_per_item_after_discount,
'1',
id
From dbo.posted_order_items_from_filemaker2 F
INNER JOIN dbo.Products P ON P.ProductCode = F.item_code
[/Code]
_____________
Code for TallyGenerator