I`m getting this error for my trigger which is suppose to prevent the updating of orders of products that have units in stock less than the quantity ordered. This is my trigger:
altertrigger tr_check_qtyon OrderDetailsforupdateasif(select Quantity from inserted i)>(select UnitsInStock from Products pinnerjoin inserted i on p.ProductID = i.ProductID)beginprint'Ordered amount cannot be greater than units in stock'rollbacktransactionend
this is how I execute the trigger:
UPDATE OrderDetails SET Quantity =40WHERE OrderID =10044AND ProductID =77