triggers updating individual rows

  • Hello

    This is probably a simple question, however I am trying to create a trigger that will update one specific row.

    I have a submission webpage and an editor webpage.

    What I would like to do is when one of the rows is edited in the editor that the one date feild updates with the new date, but other rows left untouched.

    I have a Unique ID feild called ID

    the code I have that does not work as when an update is made it modifies the Time of update feild for all the rows

    CREATE TRIGGER [update time] ON [dbo].[temp]

    FOR UPDATE

    AS

    UPDATE temp

    SET [Time of Update] = getdate()

    WHERE

    [ID] = (select[ID])

  • --FU means for update .

     

    CREATE TRIGGER tr_temp_FU_updateTime ON [dbo].[temp]

    FOR UPDATE

    AS

    SET NOCOUNT ON

    UPDATE T

    SET [Time of Update] = getdate()

    FROM dob.Temp T inner join Inserted I on T.ID = I.ID

  • Fantastic....

    thanks for you help, could not find his anywhere from my google searches...

    Works a treat

  • Check out books online (BOL). The section CREATE TRIGGER will surely help you a lot!

     

    You'll also find plenty of information on this site alone!

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

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