BULK insert with FIRE_TRIGGERS 不执行触发器 [英] BULK insert with FIRE_TRIGGERS not execute the trigger
问题描述
我正在使用以下代码批量插入 CSV 文件:
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
我有 FIRE_TRIGGERS 属性,但触发器仍未执行.触发器肯定有效,因为如果我手动插入表然后它会执行.任何帮助解决这个问题?
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 ?
推荐答案
在批量导入操作期间,您的触发器只会被触发一次,因为它被视为影响多行数据的单个语句.
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.
这篇 MSDN 文章的 C 部分,向您展示如何创建一个插入触发器来处理多行数据:http://msdn.microsoft.com/en-us/library/ms190752.aspx
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
希望有帮助.
这篇关于BULK insert with FIRE_TRIGGERS 不执行触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!