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)
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)
if exits(select * from t1 where datediff(mi,max(fday),getdate()>5)
begin
RAISERROR ('不能插入, 16, 1)
ROLLBACK TRANSACTION
end
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
)