Trigger
A special stored procedure, can not be called directly, but by adding and deleting the action to trigger, a table of an action can only have a trigger
CREATE TABLE Users
(
IDS int primary key identity (.),
Name nvarchar (10),
Class nvarchar (10),
)
CREATE TABLE Class
(
Class_code nvarchar (Ten) primary key,
Class_name nvarchar (10),
)
Delete from users where Ids=1
Method 1:
Create Trigger user_delete--which action for which table
On users-- triggers for which table
for delete-- trigger for which action
As
SELECT * from users-- after which action to perform the replacement
Method 2:
Create Trigger Users1_delete
On users
instead of Delete
As
SELECT * from Users
SELECT * from deleted
declare @a nvarchar (10);
Select @a=ids from deleted;
If @a>5
Begin
Select ' is too ugly to erase '
End
Else
Begin
Delete from users where [email protected]
End
SQL server--triggers