Trigger not firing

  • Is there code in the trigger to check that a row has actually changed?

    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
  • Sample Trigger i use

    IF(UPDATE(Authorised))

    BEGIN

    UPDATE

    tbl

    SET

    IsAuthorised = (CASE WHEN inst.Authorised = 'Yes' THEN 1 ELSE 0 END)

    FROM

    TABLE tbl

    INNER JOIN INSERTED inst ON tbl.TaskNumber = inst.TaskNumber

    END

  • sql_lock (6/2/2009)


    IF(UPDATE(Authorised))

    That trigger is not going to do anything for the update you posted. It will only execute if the Authorised column is updated, that's what the IF UPDATED line is there for.

    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

Viewing 3 posts - 1 through 4 (of 4 total)

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