select @TMP=count(*) from inserted where inserted.bno=books.bno ;
    UPDATE books SET quantity=quantity-@TMP
    from books inner join inserted
    where books.bno=inserted.bno  这里应该把where改成on,但改了还是同样的错误报出

解决方案 »

  1.   

    --try
      create trigger trg_borrow after insert
    on borrow
    as
    begin
    declare @TMP int
        select @TMP=count(*) from new where new.bno=books.bno ;
        UPDATE books SET quantity=quantity-@TMP
        from books inner join new
        where books.bno=new.bno
    end
      

  2.   

    还是有同样的问题,after只是保证所有的执行都完成吧,
      

  3.   

    --then this one?
      create trigger trg_borrow after insert
    on borrow
    as
    begin
    declare @TMP int
        select @TMP=count(*) from new where new.bno=books.bno ;
        UPDATE books SET quantity=quantity-@TMP
        where books.bno=new.bno
    end