嗨,我创建了触发器插入,它在测试字段 1 上工作正常。当我将数据复制到设置触发器的表或我使用代码插入时。插入看起来像这样:
SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
Create TRIGGER sometr ON [dbo].[mpomiar] For INSERT
AS
Begin
iNSERT INTO
[Database].dbo.[eksport] ([Repair_Date],[idKard],[Position],[error][Pos_X],[Pos_Y],[Pos_Z],[name],[model],[parent])
SELECT i.[Repair_Date],c.idKard,i.[Position],i.error,i.[Pos_X],i.[Pos_Y],i.[Pos_Theta],s.name, mo.Model, pn.Parent
FROM inserted i
inner join dbo.test t on i.idtst=t.idtst
inner join dbo.Kard c on t.idKard=c.idKard
inner join dbo.TFILE AS s ON t.idTFILE = s.idTFILE INNER JOIN
dbo.MACHINE AS mc ON t.idMC = mc.idMC INNER JOIN
dbo.PANEL AS p ON c.idPANEL = p.idPANEL INNER JOIN
dbo.PARENT AS pn ON i.idPARENT = pn.idPARENT INNER JOIN
dbo.MODEL AS mo ON pn.idMOD = mo.idMOD
where [Repair_Error] in (400,300) and c.idKard not in (select idKard from dbo.eksport)
end
但是,当触发器设置在 MS SQL Server 2005 中的真实表上时,它只会在我从代码中删除时触发
其中 [Repair_Error] 在 (400,300) 和 c.idKard 不在(从 dbo.eksport 选择 idKard)