以下在更新(UPDATE)时记录时,也会触发此触发器,我想只有在删除(DELETE)时才触发此触发器。
/******对象:Trigger[dbo].[delete]脚本日期:01/22/201411:11:34******/SETANSI_NULLSONGOSETQUOT...
/****** 对象: Trigger [dbo].[delete] 脚本日期: 01/22/2014 11:11:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[delete]
ON [dbo].[ep01]
FOR DELETE --INSERT,UPDATE,
AS
BEGIN
DECLARE @Mworkno char (8),@Mworknam char (10)
select @Mworkno=deleted.workno from deleted
select @Mworknam=deleted.worknam from deleted
IF NOT EXISTS(SELECT 1 FROM inserted) --AND EXISTS(SELECT 1 FROM deleted)
Begin
UPDATE Bed_num set workno='',worknam='' where Bed_num.workno=@Mworkno
IF NOT EXISTS(SELECT 1 FROM inserted) --AND EXISTS(SELECT 1 FROM deleted)
Begin
UPDATE cup_num set workno='',worknam='' where cup_num.workno=@Mworkno
end;
end;
以上在更新(UPDATE)时记录时,也会触发此触发器,我想只有在删除(DELETE)时才触发此触发器。 展开
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[delete]
ON [dbo].[ep01]
FOR DELETE --INSERT,UPDATE,
AS
BEGIN
DECLARE @Mworkno char (8),@Mworknam char (10)
select @Mworkno=deleted.workno from deleted
select @Mworknam=deleted.worknam from deleted
IF NOT EXISTS(SELECT 1 FROM inserted) --AND EXISTS(SELECT 1 FROM deleted)
Begin
UPDATE Bed_num set workno='',worknam='' where Bed_num.workno=@Mworkno
IF NOT EXISTS(SELECT 1 FROM inserted) --AND EXISTS(SELECT 1 FROM deleted)
Begin
UPDATE cup_num set workno='',worknam='' where cup_num.workno=@Mworkno
end;
end;
以上在更新(UPDATE)时记录时,也会触发此触发器,我想只有在删除(DELETE)时才触发此触发器。 展开
2014-01-22
展开全部
不一定是你触发器的事情,有些前台程序在修改数据时不向后台提交update语句,而是先提交一个delete,然后再提交一个insert,这个也要检查一下。
追问
哦,谢谢提示!分还是给你吧,我再仔细查查其它原因!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询