August 26, 2011 at 1:48 pm
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
August 26, 2011 at 1:59 pm
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
August 26, 2011 at 2:14 pm
Thank you so much. It works.
August 26, 2011 at 2:17 pm
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