create trigger tr_insert on t1
instead of insert
as
insert t1
select * from inserted i
where not exists(
select * from t1 
where name=i.name 
and context=a.context 
and fday between dateadd(minute,-5,a.fday) and a.fday)

解决方案 »

  1.   

    name  context 设为主键触发器里写
    if exits(select * from t1 where datediff(mi,max(fday),getdate()>5)
    begin
    RAISERROR ('不能插入, 16, 1)
    ROLLBACK TRANSACTION
    end
      

  2.   

    zjcxc(邹建) ( )  is right 俺们只能学习
      

  3.   

    create trigger tr_insert on t1
    instead of insert
    as
    insert t1
    select * from inserted i
    where not exists(
    select * 
             from t1 ,i
    where name=i.name 
    and context=i.context 
    and fday between dateadd(minute,-5,i.fday) and i.fday
                     )