我在一张类似这样的表上有一个触发器:
ALTER TRIGGER [shoot_sms]
ON [dbo].[MyTable]
AFTER INSERT
AS
begin
declare @number bigint
declare @body varchar(50)
declare @flag int
select @number=number,@body=body,@flag=flag from inserted
if(@flag=0)
begin
insert into temptable (number,body,status)
select @number,@body,'P'
end
end
现在我在 mytable 中创建两个条目,如下所示:
insert into mytable(number, body, flag)
values(3018440225, 'This is test', 0)
insert into mytable(number, body, flag)
values(3018440225, 'This is test', 0)
我一次执行这些查询,但是对于这两个查询,触发器只触发一次,并且只为第一个查询执行任务。
如何使它适用于两个插入语句?