question archive Modify the trigger below to execute its check code only if the Quantity column is updated

Modify the trigger below to execute its check code only if the Quantity column is updated

Subject:Computer SciencePrice: Bought3

Modify the trigger below to execute its check code only if the Quantity column is updated.

( I am using Adventurework SQL for reference & not MYSQL)

Create Trigger tgrExcessInventory On Production.ProductInventory

After Insert, Update

AS IF Exists (Select 'True' from inserted i Join Deleted d

on i.productID=d.productID

And i.locationID=d.locationID where (d.quantity+I.quantity)>=800 or i.quantity>=800)

 

Begin

RAISERROR ('Error Occurred, Quantity cannot exceed 800', 17,1)

End

 

 

 

 

This is what I have so far as the modification. Does the query responds to the question? or does it need further modifications

 

 

Alter Trigger tgrExcessInventory On Production.ProductInventory

After Update

AS IF Exists (Select 'True' from inserted i Join Deleted d

on i.productID=d.productID

And i.locationID=d.locationID where (d.quantity+I.quantity)>=800 or i.quantity>=800)

 

Begin

RAISERROR ('Error Occurred, Quantity cannot exceed 800', 17,1)

End

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE