drop trigger if exists dbo.tr_check_qty
go
CREATE TRIGGER dbo.tr_check_qty
on orderdetails
for insert, update
as
begin
if (select quantity from inserted) > (select Products.UnitsInStock from A010_Project.dbo.Products where ProductID in (select ProductID from inserted))
rollback transaction
print 'QTY is invalid'
end;
go
My code is not working as expected. any help. Thanks.
please check the image for more details