SQL trigger

  • Hi all,

    I've got this trigger that i've somehow thumbled together.

    I wanted to update a field called "Lastupdated" with the current date which it does do, but it's updating every record in the table. i'm not sure how to tell it to only update the particular row and not all of them

    help!!

    Thanks Dave

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TRIGGER trig_updateQ1ans

    ON tbl_Question1Answers

    FOR UPDATE

    AS

    IF NOT UPDATE(questionAns)

    BEGIN

    RETURN

    END

    UPDATE tbl_Question1Answers set lastupdated = getdate()

    GO

  • Duplicate post. No replies to this thread please. Direct replies to: http://www.sqlservercentral.com/Forums/Topic633463-8-1.aspx

    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 2 posts - 1 through 1 (of 1 total)

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