Track column changes

  • Hello everyone.

    Could you please remember me how to catch the time when some table got updates in a particular column?

    MS SQL Server 2016

    Thanks a lot in advance.

  • Trigger.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Are you only checking for a single column changing? You can audit/use Extended Events for this, but if you want to capture the time, a trigger will do this. You'll want to compare the inserted and deleted tables for the column to determine a change and update some other value. However, if you do this for one column what about others? Will your requirements change to know when the row was updated? Or the history of the row?

    There are ways to do this, but think a little deeper about what things might come about if you know when a column changed for a row. Will there be other requirements?

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

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