www.1862.net > triggEr DElEtE

triggEr DElEtE

CREATE TRIGGER A_table_delete ON A FOR DELETE BEGIN DECLARE @UserID nvarchar(128); SET @UserID = (SELECT UserID FROM deleted); UPDATE B set PropRight=xxx WHERE UserID=@UserID; END GO

应该是对的啊 你试一下 IF DELETE BEGIN 里面打印一下呢 END

INSERT: 表1 (ID,NAME)表2 (ID,NAME)当用户插入表1数据后,表2也被插入相同的数据CREATE TRIGGER TRI1ON 表1FOR INSERTASBEGIN INSERT INTO 表2 SELECT * FROM INSERTEDENDGO DELETE: 表1 (ID,NAME)表2 (ID,AGE,GENDER)当用户删除表1某条ID的数...

CREATE OR REPLACE TRIGGER test_trg BEFORE INSERT OR DELETE ON TEST1 BEGIN CASE WHEN inserting THEN inser into test2 value :new; WHEN deleting THEN delete test2 where id=:old.id; END CASE; END;

DECLARE @IsInsert bit, @IsUpdate bit, @IsDelete bit IF EXISTS(SELECT 1 FROM inserted) AND NOT EXISTS(SELECT 1 FROM deleted) SET @IsInsert = 1 ELSE SET @IsInsert = 0 IF EXISTS(SELECT 1 FROM inserted) AND EXISTS(SELECT 1 FROM del...

create trigger tr_a on a for insert,update,delere as begin IF EXISTS(SELECT 1 FROM inserted) AND NOT EXISTS(SELECT 1 FROM deleted) BEGIN -- 插入触发. INSERT INTO B SELECT inserted.a FROM inserted; END; IF EXISTS(SELECT 1 FROM i...

CREATE TRIGGER [dbo].[trig_学生表_Delete] on [dbo].[学生表] for Delete AS BEGIN declare YB cursor for select user_Id from deleted; --这里的user_Id要和下面的匹配 open YB; declare @user_Id varchar(50); fetch next from YB into @us...

怎么可能,FOR DELETE 这都标明是delete触发器了,不会在update时触发的,你是不是另写过update触发器或者其他表的触发器关联了这个表

可以的。 create trigger mytrigger on tableName after insert,update,delete as begin ..... end

DELIMITER // CREATE TRIGGER TR_DeleteStudents BEFORE DELETE ON students FOR EACH ROW BEGIN Delete FROM detail WHERE Name = old.name ; END; //

网站地图

All rights reserved Powered by www.1862.net

copyright ©right 2010-2021。
www.1862.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com