关于SQLServer2005的学习笔记多触发器执行问题
程序员文章站
2022-03-26 14:12:27
...
CREATE TABLE TestA ( a VARCHAR(20) ); CREATE TABLE TestB ( a VARCHAR(20) ); ALTER TRIGGER [Tri_Test1] ON TestA AFTER INSERT,UPDATE AS SET NOCOUNT ON DECLARE @a VARCHAR(20) SELECT @a=a FROM INSERTED IF @a='A' OR @a='a' BEGIN RAISERROR ( '
CREATE TABLE TestA
(
a VARCHAR(20)
);
CREATE TABLE TestB
(
a VARCHAR(20)
);
ALTER TRIGGER [Tri_Test1] ON TestA
AFTER INSERT,UPDATE
AS
SET NOCOUNT ON
DECLARE @a VARCHAR(20)
SELECT @a=a FROM INSERTED
IF @a='A' OR @a='a'
BEGIN
RAISERROR ( ' 该条记有问题 , 不能重复保存! ', 16, 1 )
ROLLBACK TRAN
RETURN
END
ALTER TRIGGER [Tri_Syn_Test1] ON TestA
AFTER INSERT,UPDATE
AS
SET NOCOUNT ON
INSERT INTO TestB SELECT a FROM inserted
COMMIT;