ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 一个简单的触发器

一个简单的触发器

原创 Linux操作系统 作者:iSQlServer 时间:2010-05-21 17:02:41 0 删除 编辑

create table abcd (id int not null,)

go

create trigger tr_abcd on abcd for insert ,delete,update

as

if exists(select * from inserted where id%2=0)

begin

      roallback

      raiserror 50001 "不允许插入偶数记录!"

      return

end

go

insert into abcd select 1      ----------id=1

insert into abcd select 2      ----------报错:不允许插入偶数记录

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16436858/viewspace-663372/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-10-17

  • 博文量
    1319
  • 访问量
    2342901