/**********设A B C三表在同一数据库F,触发器名updatea
USE [F]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[updatea]
ON [dbo].[C]
FOR INSERT
AS
BEGIN
DECLARE @valuebb int,@valuecc int,@valueid int;
SELECT @valueid=id FROM inserted
SET @valuebb=(SELECT SUM(b) FROM B WHERE id=@valueid);
SET @valuecc=(SELECT SUM(c) FROM C WHERE id=@valueid);
IF @valuebb=@valuecc
BEGIN
UPDATE dbo.A SET a=@valuebb-@valuecc WHERE id=@valueid
END
END