Compare yesterday's data to today's

  • Newbie question...

    Our home office overwrites a table every night with new data. I want to know when a new row appears in the table, but if they overwrite the data, how can I do this? The only thing I can think of is copy the table each evening before they overwrite it, and compare the new data with my copy. Is there any easier way?

    TIA for the help!

  • Hi

    I believe if I'm understanding your question adding another column to the table and making the default value of that column as "getdate()" this will give you the exact time that row was added or changed.

  • Thanks so much for the quick reply!

    Unfortunately I cannot change the table; our home office has complete control over this table. Every night they delete the current contents of the table and loads new data. It "should" be the same customer base, however once in awhile a new customer is added. So the only way I can think of doing it is to copy the table daily, when the new data is loaded the next day, do a left join and see if anything is new.

    Any other ideas?

  • Shairal-763732 (10/19/2009)


    Newbie question...

    Our home office overwrites a table every night with new data. I want to know when a new row appears in the table, but if they overwrite the data, how can I do this? The only thing I can think of is copy the table each evening before they overwrite it, and compare the new data with my copy. Is there any easier way?

    TIA for the help!

    You only need the PK from the table to compare with but you have the correct idea. Properly indexed, it will be very fast. And, if you use SELECT/INTO to create the new "master", that will be very fast as well. That will also allow you to determine if they've deleted rows, as well.

    --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)

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

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