none
SQL Server Trigger to Update another table if a value in another table changes

    Question

  • This is the first time ive thoought about using triggers.

    I have a table  TABLEA for example

    ID      JF                       UpdatedJF    UpdatedFJDate

    1,      111,                         NULL,       NULL,

    2,      112 ,                        NULL,       NULL,

    This table is used to update another table with forexample TABLEB

    ID,    Comment

    1,     'JF = 111 No changes applied'

    However the first table can change at any time with updates pushed to it. So if for example this happens

    ID      JF                       UpdatedJF    UpdatedFJDate

    1,     111                         222         25/07/2013

    2,      112                         NULL       NULL

    I want that update to trigger a change in Table B

    Update TableB

    Set Comments = 'JF = 111. Updated JF 222'

    Where tableA UpdatedJF has changed

    and TableA ID matches TableBID

    Ive had a go at putting this together but I dont know enough about triggers to make any headway. Any informaiton would be greatly appreciated

    Debbie

    Thursday, July 25, 2013 12:37 PM

Answers

All replies