从表中删除行会导致另一行自动插入另一行?怎么做?

时间:2012-07-03 05:36:42

标签: sql-server-2008

谁能告诉我如何实现这一目标?

它看起来像一个设置。

请帮忙!

1 个答案:

答案 0 :(得分:0)

CREATE TRIGGER trgAfterDelete ON <yourFirsttable> AFTER DELETE
AS
    select @blah = <yourCol1>, @blih = <yourCold2> from deleted;    

    insert into <YourSecondTable>(..., blah, blih)
        values(..., @blah, @blih);
GO