Quantcast
Channel: SQL Server Express forum
Viewing all articles
Browse latest Browse all 3319

“The transaction ended in the trigger. The batch has been aborted” error

$
0
0

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

Viewing all articles
Browse latest Browse all 3319

Trending Articles