--触发器中,对导入的数据进行去重复处理 create trigger tr_insert on 表 instead of insert as insert 表 select * from inserted i where not exists( select * from 表 where 唯一键字段名=i.唯一键字段名) go--导入的时候,如果用bulk insert,加上FIRE_TRIGGERS选项 bulk insert 表 from 'c:\a.txt' with(FIRE_TRIGGERS)--如果用bcp导入,加上在-h参数中使用FIRE_TRIGGERS选项 bcp 库名..表名 in "c:\a.txt" /T /h"FIRE_TRIGGERS"
create trigger tr_insert on 表
instead of insert
as
insert 表
select * from inserted i
where not exists(
select * from 表 where 唯一键字段名=i.唯一键字段名)
go--导入的时候,如果用bulk insert,加上FIRE_TRIGGERS选项
bulk insert 表 from 'c:\a.txt'
with(FIRE_TRIGGERS)--如果用bcp导入,加上在-h参数中使用FIRE_TRIGGERS选项
bcp 库名..表名 in "c:\a.txt" /T /h"FIRE_TRIGGERS"