Link to home
Start Free TrialLog in
Avatar of IScoop
IScoop

asked on

SQL Statement with multiple updates

I have two updates to two different tables that need to happen in one stored procedure. The first update relies on the second update not happening until the first update has run. I can get them both to work accurately when run independent of each other however together the only one that works is the second one. Any help would be gratefully appreciated.
UPDATE Inventory
SET Quantity=i.Quantity-p.Quantity FROM PO_Hist p, Inventory i
WHERE i.Description=p.ProdDescr AND p.AM_PM = 'PM' AND p.Date=Convert(date, GETDATE()) AND p.SubDept='Grocery' AND p.Submitted=NULL
GO
UPDATE PO_Hist
SET Submitted=1 FROM PO_Hist p, Inventory i
WHERE i.Description=p.ProdDescr AND p.AM_PM = 'PM' AND p.Date=Convert(date, GETDATE()) AND p.SubDept='Grocery'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial