About trigger

  • I've have following table,

    tblHIT - this table will reveive record every minutes

    Date | Time | Main_ID | Hit

    ------------------------------------

    3/1/2006 | 100 | 200 | 8700

    ...

    ...

    ...

    4/14/2008 | 100 | 200 | 4500

    4/14/2008 | 100 | 201 | 8700

    4/14/2008 | 200 | 200 | 3500

    4/14/2008 | 300 | 201 | 7700

    ...

    ...

    I've also 1 job in SQL Server Agent will execute STORED PROCEDURE and will filter 7 days record before from current date and insert it into tblHIT_7days. tblHIT_7days shown as follow

    tblHIT_7days

    Date | Time | Main_ID | Hit

    ------------------------------------

    3/7/2008 | 100 | 200 | 8700

    ...

    ...

    ...

    4/13/2008 | 100 | 200 | 4500

    4/13/2008 | 100 | 201 | 8700

    4/13/2008 | 200 | 200 | 3500

    4/13/2008 | 300 | 201 | 7700

    I've plan to create TRIGGER. This TRIGGER will insert the appropriate record from tblHIT into tblHIT_7days and also delete a appropriate record in tblHIT_7days. This INSERT and DELETE transaction depend on current date.

    Is it possible, TRIGGER can do this?

  • Yes... it's possible... give it a whirl.

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

  • Kindest Jeff Moden,

    Tq for that info. 🙂

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

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