• Triggers fire once per insert/update/delete, not once per row. Your line here

    select @stokkod=stokkod,@quantity=quantity from deleted

    Will fetch only one of the values from the deleted table, while there are as many as rows that you delete.

    Maybe something more like this... (rough, untested)

    UPDATE stok

    SET stokquantity =stokquantity-deleted.quantity

    FROM stok inner join deleted on

    stok.stokkod = deleted.stokkod

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass