﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server Express  / delete trigger is not working as i want / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 23:58:10 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: delete trigger is not working as i want</title><link>http://www.sqlservercentral.com/Forums/Topic531303-324-1.aspx</link><description>Dear friend it worked exactly as i want ,and by the way thanks to your explanation i think i got the logic thank you very very much, it was a lifesaver answer for me ;)</description><pubDate>Thu, 10 Jul 2008 14:26:03 GMT</pubDate><dc:creator>delta dirac</dc:creator></item><item><title>RE: delete trigger is not working as i want</title><link>http://www.sqlservercentral.com/Forums/Topic531303-324-1.aspx</link><description>Triggers fire once per insert/update/delete, not once per row. Your line here[code]select @stokkod=stokkod,@quantity=quantity from deleted[/code]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)[code]UPDATE stokSET stokquantity =stokquantity-deleted.quantity       FROM stok inner join deleted onstok.stokkod = deleted.stokkod[/code]</description><pubDate>Thu, 10 Jul 2008 00:19:04 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>delete trigger is not working as i want</title><link>http://www.sqlservercentral.com/Forums/Topic531303-324-1.aspx</link><description>Hi everyonei 'm using sql server express 2005 and i have tree triggers for insert delete and updateİ am making my inserts ,deletes or updates through ADO.NET (so multiple rows in an update or delete or insert)i have a sales table and a sales details table and i am making a plus operation on stock when it's an insert and the opposite for deletes(putting back the stocks quantity),The insert works fine (when i make an insert all the godds that sold are on the plus values and taht's right), the update is also fine but when it comes to delete ,it updates only the fist stocks that sold and the other rows are untouchedhere's my delete triggerALTER TRIGGER [dbo].[faturagdelete] on [dbo].[fatura]for deleteAS declare @stokkod int,@quantity decimal(8,2)select @stokkod=stokkod,@quantity=quantity from deletedUPDATE stokSET stokquantity =stokquantity-@quantity       FROM stok  WHERE stok.stokkod =@stokkodwhy did this trigger updated only the First items quantity and leave the rest(the same methot is working on insert trigger bu this ones not)i'll be very appreciate for any ideas thanks.</description><pubDate>Wed, 09 Jul 2008 18:04:23 GMT</pubDate><dc:creator>delta dirac</dc:creator></item></channel></rss>