use of trigger to update history table

  • My database has 2 tables, the first holds just the most recent data collected used for a display. The second table isnearly identicle to the first but holds all transactions of the first table as historical data.

    What I need is a trigger to detect when a line is added to the first table and have that data enterred into the second history table.

    I can trigger on an insert since my app deletes the current record in the display table and then inserts the new data.

    Can anyone help me clarify how to format a trigger event to handle this?

  • CREATE TRIGGER Itr_T_Current
                ON T_Current
    FOR INSERT
    AS 
    insert into T_History
    select * from inserted
    GO

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

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

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