Home > Database > Mysql Tutorial > Sqlserver触发器 示例

Sqlserver触发器 示例

WBOY
Release: 2016-06-07 15:14:33
Original
1208 people have browsed it

insert 触发器 示例 create trigger tri_insert on student for insert as declare @student_id char(10) select @student_id=s.student_id from student s inner join inserted i on s.student_id=i.student_id if @student_id='0000000001' begin raiserro

insert 触发器示例

create trigger tri_insert

on student

for insert

as

declare @student_id char(10)

select @student_id=s.student_id from

student s inner join inserted i

on s.student_id=i.student_id

if @student_id='0000000001'

begin

raiserror('不能插入1的学号!',16,8)

rollback tran

end

go

update触发器示例

create trigger tri_update

on student

for update

as

if update(student_id)

begin

raiserror('学号不能修改!',16,8)

rollback tran

end

go

delete触发器示例

create trigger tri_delete

on student

for delete

as

declare @student_id varchar(10)

select @student_id=student_id from deleted

if @student_id='admin'

begin

raiserror('错误',16,8)

rollback tran

end

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