========================================================== =
-- Insert trigger
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 = '123'
Begin
Raiserror ('the student ID of 1 cannot be inserted! ', 16, 8)
Rollback tran
End
Go]
========================================================== ========
-- Update trigger
Create trigger tri_update
On student
For update
As
If Update (student_id)
Begin
Raiserror ('the student ID cannot be modified! ', 16, 8)
Rollback tran
End
Go
==================================== -- Delete trigger
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 ('error', 16, 8)
Rollback tran
End
========================================================== ==========
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service