79523954

Date: 2025-03-20 19:54:15
Score: 2.5
Natty:
Report link

Thanks @Guillaume, but I think I found a better way that worked adding all the constraints. Here is what I did. Thanks for your effort though.

UPDATE ol
SET ol.RateTierIds = rpt_new.Id
FROM OrderLines ol
JOIN RatePlanTiers rpt_old ON ol.RateTierIds = rpt_old.Id
JOIN RatePlans rp_old ON rpt_old.RatePlanIDNumber = rp_old.Id AND rp_old.Name = 'Old Rate Plan'
JOIN RatePlans rp_new ON rp_new.Name = 'New Rate Plan'
JOIN RatePlanTiers rpt_new
ON rpt_new.RatePlanIDNumber = rp_new.Id
AND rpt_new.Price = rpt_old.Price
AND rpt_new.MinQty = rpt_old.MinQty
AND rpt_new.BundleId = rpt_old.BundleId;
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Guillaume
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: ray805