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/ ,如需转载,请注明出处,否则将追究法律责任。