如果B表是有记录号ID的话就这样
CREATE TRIGGER [ABC] ON [dbo].[b] 
FOR  DELETE 
AS
declare @k int;
declare @id int;
begin
select @k=x,@id=id from deleted;
update a set y=y-@k where id=@id
end

解决方案 »

  1.   

    CREATE TRIGGER tri_b ON b
    FOR  DELETE 
    AS
    update a set a.y=a.y-delete.x 
    from deleted where a.id=deleted.id
      

  2.   

    如果一次可以删除多条记录的话,在触发器中要使用游标。对deleted表中的记录进行循环更新。
      

  3.   

    Create trigger 触发器名 on b表
    for delete 
    as
    BEGIN
      declare @yyyy int  select @yyyy=字段x
      from deleted 
      
      update 表a set 字段y=字段y-@yyyy where ......
    /* 我想你一定应该有Where 后的内容吧!!*/END
    这样可以了吗??b表
    a表
    字段y
    字段x
      

  4.   

    CREATE TRIGGER csdntest
    ON b
    FOR DELETE
    AS
    DECLARE @var1 int
    SELECT @var1=interval FROM deleted
    UPDATE a SET y=y-@var1