日期:2014-05-18  浏览次数:20656 次

请教一个简单的触发器如何写
工人表workertable(workerid   int,   name   varchar(20));
刷卡表cardtable(workerid   int,       brushtime   datatime);

当删除   workertable中记录时,通过触发器删除删除card中相应记录



------解决方案--------------------
CREATE TRIGGER tr_delete
ON [工人表]
AFTER DELETE
AS
BEGIN
DELETE FROM [刷卡表]
WHERE [刷卡表].workerid = deleted.workerid
END
------解决方案--------------------
CREATE TRIGGER tr_delete
ON [工人表]
AFTER DELETE
AS
BEGIN
SET NOCOUNT ON --加上这句
DELETE FROM [刷卡表]
WHERE [刷卡表].workerid = deleted.workerid
END
在某些语言中(如Delphi)由于ADO的BUG,导致出现问题!