当前位置:Gxlcms > mysql > 关于SQLServer2005的学习笔记多触发器执行问题

关于SQLServer2005的学习笔记多触发器执行问题

时间:2021-07-01 10:21:17 帮助过:26人阅读

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;

人气教程排行