February 8, 2010 at 4:00 pm
I'm getting an Incorrect syntax near the keyword 'ON' and i'm not sure why. This is the first time that i've ever used the Merge command but i thought i was doing it right, any help would be appreciated.
MERGE INTO PurchaseOrderReorderCheck AS target
USING aaInventoryReorderLocalStock as source
ON (source.Location=target.IplStockLocation)
ON (source.AlternatePart=target.IplPartNumber)
WHEN MATCHED THEN
UPDATE SET IplReorderPoint = 1, IplMacroProcessed = 0 WHERE (IplStockLocation =target.IplStockLocation) AND (IplPartNumber = target.IplPartNumber)
UPDATE SET IplReorderPoint = 0, IplMacroProcessed = 0
WHERE (IplStockLocation =target.IplStockLocation) AND (IplPartNumber = source.Part)
WHEN NOT MATCHED BY TARGET THEN
INSERT INTO PurchaseOrderReorderCheck
(IplReorderPoint, IplMacroProcessed, IplPartNumber, IplStockLocation)
VALUES (1, 0, source.AlternatePart, source.Location)
UPDATE PurchaseOrderReorderCheck
SET IplReorderPoint = 0, IplMacroProcessed = 0
WHERE (IplStockLocation =source.Location) AND (IplPartNumber = source.Part)
February 10, 2010 at 1:42 pm
The firsrt thing is the second ON clause should be an AND:USING aaInventoryReorderLocalStock as source
ON (source.Location=target.IplStockLocation
AND source.AlternatePart=target.IplPartNumber)
...
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply