BULK insert with FIRE_TRIGGERS not execute the trigger

10,647

During a bulk-import operation, your trigger will be fired only once because it's considerated as a single statement that affects multiple rows of data.

Your trigger should be able to handle a set of rows instead a single rows. Maybe this is the reason because your manual insert test is working fine and your bulk import is failing.

The C section of this MSDN article, show you how to create an insert trigger to Handle Multiple Rows of Data: http://msdn.microsoft.com/en-us/library/ms190752.aspx

Hope it helps.

Share:
10,647
user1292656
Author by

user1292656

Updated on August 04, 2022

Comments

  • user1292656
    user1292656 almost 2 years

    I am using the following code to Bulk insert a CSV file:

        BULK
    INSERT CustomSelection
    FROM 'c:\asd\a1.csv'
    WITH
    (
    FIRSTROW =2,
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n',
    FIRE_TRIGGERS
    )
    GO
    

    I have the FIRE_TRIGGERS property but the trigger is still not executing. The trigger works for sure because if i manually insert into the table then it executes. Any help to solve that ?