Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:51:39
Original
1216 people have browsed it

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;

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template