• Hi Sergiy,

    There's no need to. An INSTEAD OF UPDATE trigger will enver fire on an UPDATE statement that is executed in the context of the trigger. Cut and pastte the code below in Query Analyzer for a quick proof.

    CREATE TABLE Test (A int NOT NULL PRIMARY KEY,

                       B int)

    go

    INSERT INTO Test (A, B)

    VALUES (1, 1)

    go

    CREATE TRIGGER TestTrig

    ON Test

    INSTEAD OF UPDATE

    AS

    PRINT 'Trigger nest level ' + CAST(TRIGGER_NESTLEVEL() AS varchar(3))

    UPDATE Test

    SET    B =   (SELECT inserted.B

                  FROM   inserted

                  WHERE  inserted.A = Test.A)

    WHERE EXISTS (SELECT inserted.B

                  FROM   inserted

                  WHERE  inserted.A = Test.A)

    go

    UPDATE Test

    SET    B = 2

    WHERE  A = 1

    go

    SELECT * FROM Test

    go

    DROP TRIGGER TestTrig

    DROP TABLE Test

    go

    Best, Hugo


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/