UPDATE orderdetails
JOIN orders ON orderdetails.OrderID = orders.OrderID
SET orderdetails.QtyOnPackingSlip = NULL
WHERE orders.orderstatus IN ('Ready to Ship','Pending Shipment') AND orderdetails.QtyOnHold <> 0;

UPDATE orderdetails
SET QtyOnPackingSlip = NULL, QtyOnHold = Quantity, QtyShipped = 0
WHERE QtyOnPackingSlip > 0 AND QtyOnPackingSlip < 999;

UPDATE orderdetails
JOIN orders ON orderdetails.OrderID = orders.OrderID
SET orderdetails.QtyOnPackingSlip = 0
WHERE orders.orderstatus IN ('Ready to Ship','Pending Shipment') AND orderdetails.QtyOnHold = 0;

-- This is for cancels, don't want to set the QtyOnPackingSlip to 0 since that is how we mark things as recevied/shipped
UPDATE orderdetails
JOIN orders ON orders.orderid = orderdetails.orderid
SET orderdetails.QtyOnPackingSlip = -1
WHERE orderdetails.Quantity = 0 
AND orderdetails.QtyOnPackingSlip IS NULL
AND orders.orderstatus != 'New';