views:

268

answers:

2

In SQL Server 2000, by default, does a DELETE query cause a table's UPDATE trigger to be executed?

I know I can define a trigger that will be executed on both DELETE and UPDATE, but I thought I would verify that this is in fact required first.

+1  A: 

dump this in your trigger and check for yourself

IF @@ROWCOUNT > 0 
BEGIN 
    IF EXISTS (SELECT 1 FROM inserted) 
    BEGIN 
        IF EXISTS (SELECT 1 FROM deleted) 
            PRINT 'update'; 
        ELSE 
            PRINT 'insert'; 
    END 
    ELSE 
        PRINT 'delete'; 
END
SQLMenace
Thanks, I finally got around to trying this code out. It was useful for helping me find out the answer. That being said, I have accepted Chochos' answer because he had the actual answer to the question. Thanks!
Wally Lawless
+7  A: 

A DELETE does not fire UPDATE triggers. If you have a trigger defined to be fired on DELETE and also on UPDATE then it will be executed on a DELETE but that's because it's also a DELETE trigger.

Chochos