If only the FOR keyword is specified, the default value is the AFTER trigger.
========================================================== =
-- 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