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

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;

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...

ALTER TRIGGER [ygdelete] ON [dbo].[Student] FOR DELETE AS BEGIN delete slt_course where studentid in (select studentid from deleted) END

对于一个表,有多个触发器,其中有一个是 INSTEAD OF 的情况下。其他的触发器将失去作用。例如:CREATE TRIGGER InsertTest ON test_sub FOR INSERTASBEGIN PRINT('INSERT test_sub!');END;GoCREATE TRIGGER InsertTest2 ON test_sub INSTEAD OF...

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的数...

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...

使用delete 触发器格式: CREATE trigger tri_update on tablename for delete as begin --sql code end 例: CREATE trigger tri_update on tablename1 --触发的表名 for delete as begin declare @del_id varchar(40) select @del_id = id fro...

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

create trigger tr_delete on 课程表 for delete as begin delete t1.* from 教师任课表 t1, deleted t2 where t1.课程号=t2.课程号 delete t1.* from 学生选课表 t1, deleted t2 where t1.课程号=t2.课程号 end

网站地图

All rights reserved Powered by www.1862.net

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