David Glover
asked on
Why does my trigger fire on Update but not on Insert?
Can you guys suggest why my trigger only works for mass update but not for mass insert?
Reagrds,
CREATE TRIGGER [dbo].[ExampleTrigger]
ON [dbo].[ExampleTable]
AFTER INSERT, UPDATE
AS
BEGIN
SET NOCOUNT ON;
UPDATE ExampleTable SET ExampleTable.ExampleField= 1
FROM ExampleTable S INNER JOIN Inserted I
ON S.ExampleID = I.ExampleID
END
I realise the code is a bit redundant by virtue of setting 1 to ExampleField... in my real world scenario this is a function derived value.Reagrds,
No, the trigger looks OK to me, for either INSERTs or UPDATEs.
ASKER
Hi Scott,
I've examined this more closely and indeed it does work when I insert a record.
Something I didn't mention was that prior to this single record insert test I was bulk inserting data using SSIS integration using identity insert... I am presuming something about this doesn't cause triggers to fire?
Regards,
I've examined this more closely and indeed it does work when I insert a record.
Something I didn't mention was that prior to this single record insert test I was bulk inserting data using SSIS integration using identity insert... I am presuming something about this doesn't cause triggers to fire?
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Problem was definitely linked to the SSIS, couldn't see a don't fire triggers flag to set mind, I have worked around it anyhow.
Thanks Scott!
Thanks Scott!