Trigger for Group Inserts and Updates

  • Hi, I have the following Trigger on one of my tables. Looks like this trigger is not good for Group updates. Can someone help me in handling the group updates in the Trigger?/ Thank you

    CREATE TRIGGER [trg_test]

    ON test

    FOR INSERT,UPDATE

    AS

    begin

    DECLARE @test_id INT

    select @test_id= test_id

    from inserted

    insert into Test_Audit(test_id)

    select @test_id

    end

  • Rather try this:

    CREATE TRIGGER [trg_test]

    ON test

    FOR INSERT,UPDATE

    AS

    begin

    insert into Test_Audit(test_id)

    (

    select test_id

    from inserted

    )

    end

  • Thank you so much. It works.

  • ssismaddy (8/26/2011)


    Thank you so much. It works.

    No problem 🙂

    Remember that the "inserted" table contains ALL values that were updated/inserted.

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

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