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

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

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

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

在SQL中,触发器是一种特殊类型的存储过程,它不同于SQL的存储过程。触发器主要是通过事件进行触发而被执行的,而存储过程可以通过存储过程名字而被直接调用。当对某一表进行诸如UPDATE、 INSERT、 DELETE 这些操作时,SQL Server 就会自动执行...

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

CREATE OR REPLACE TRIGGER TRIGGER_truncate BEFORE delete ON DATABASEbegin if ora_login_user not in ('SYS', 'SYSTEM') THENRaise_application_error(-20001, 'You have no privilege to delete!'); end if;end;

网站地图

All rights reserved Powered by www.1862.net

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