欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2023-12-25 11:27:33
...

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;

上一篇:

下一篇: