CREATE TRIGGER UpdateSafeBatch
ON ClientService
AFTER UPDATE
AS
BEGIN
IF NEW.Closed != OLD.Closed THEN
UPDATE SafeBatch SET SafeBatch.TotalVisa=SafeBatch.TotalVisa+ClientService.TotalVisa,
SafeBatch.TotalCash=SafeBatch.TotalCash+ClientService.TotalCash,
SafeBatch.Total=SafeBatch.Total+ClientService.Total,
WHERE SafeBatch.Id=ClientService.SafeBatchId
END
GO
答案 0 :(得分:0)
CREATE TRIGGER UpdateSafeBatchAbdallah
ON ClientService
AFTER UPDATE
AS
BEGIN
--IF NEW.Closed != OLD.Closed THEN
UPDATE SafeBatch SET TotalVisa+=inserted.TotalVisa,
TotalCash+=inserted.TotalCash,
Total+=inserted.Total
FROM inserted
WHERE SafeBatch.Id=inserted.SafeBatchId and inserted.Closed=1
END
GO