SQL server--triggers

Source: Internet
Author: User

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

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.