How to tell if table updated?

  • We have a process that populates a table from a flat file. Is there anyway I can tell when this table is updates? Is there a system field or anything of the like?

  • Why not place a step at the end of the job to send out notification that the update is complete? Or assign a trigger to the table to log information to another table that updates have taken place?



    Shamless self promotion - read my blog http://sirsql.net

  • May just have to do that, I wasn't sure if there maybe was a system field to say when the table was last updated

  • I have the same question. To solve my problem I have defined a date/time field in the tabel with the formula 'getdate()'. Everytime a record is inserted it will carry the date and time of update. In that way I can tell which updaterun effected the table.

    I anyone has a more elegant of efficient way I also would like to learn that.

    Menno

  • Menno,

    Your solution will only work when you insert nwe records.

    To be able to it with updates you have to implement a (befor) trigger on update if you want to upgrade the same record, or an after trigger if you only want to store the last update time in a separated table.

    Using a separated table has the advantage to not to modify the original table structure (sometimes you are not allowed to do this).

    As an asnwer to cedar72: No there is no system columns saying when a table has been updated you only can see when the table has been created (crdate column in the sysobjects table)



    Bye
    Gabor

  • if you are on SQL 2000, use CHECKSUM_AGG function.

    see BOL for sample on how to use this function.


    -- Amit



    "There is no 'patch' for stupidity."



    Download the Updated SQL Server 2005 Books Online.

  • Any particular reason you can't add the GetDate() to the insert statement?

    I realize you are inserting from a flat file, but even if it's a DTS package using data transformation it's relatively simple to convert that to a SQL insert/select statement and then add the GetDate as the last column.

     

    If you need to track updates as well as inserts, then you'll have to to go with the trigger.


    Thanks, and don't forget to Chuckle

Viewing 7 posts - 1 through 6 (of 6 total)

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