CREATE TRIGGER TRI_bulkDELETEINSTOCK ON instock FOR DELETE AS BEGIN DECLARE @storeid smallint, @totalquantity int ,@wineid smallint SELECT @storeid= d.storeid FROM deleted d select @wineid = wineid from instock where wineid =@wineid select @totalquantity = SUM(QUANTITY) FROM instock WHERE storeid = @storeid IF EXISTS(SELECT storeid FROM bigstores WHERE storeid =@storeid ) BEGIN delete from bigstores where StoreId in (select storeid from instock where wineid =@wineid group by storeid having @totalquantity <50000 ) END END GO
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)