How to create trigger only when successful updatation of a column value happens.

  • CREATE TABLE TriggerTest (Value int)

    GO

    INSERT INTO TriggerTest VALUES (1)

    GO

    CREATE TRIGGER tr_TriggerTest ON TriggerTest

    AFTER UPDATE AS

    BEGIN

    SET NOCOUNT ON;

    IF UPDATE(Value)

    PRINT 'The trigger fired'

    ELSE

    PRINT 'The trigger did not fire'

    END

    GO

    --Set Value equal to itself

    UPDATE TriggerTest SET Value = Value

    --SELECT * FROM TriggerTest

    DROP TABLE TriggerTest

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply