SQL Server triggers

Source: Internet
Author: User

Create TRIGGER [dbo]. [Tr_customer_info]
on [dbo]. [T_customer_info]
After UPDATE
As
Begin

if ((((select Bank_number from inserted) <> (select Bank_number from deleted)
or ((select Mobile_phone from inserted) <> (select Mobile_phone from deleted)
or ((select email from inserted) <> (select Mail from deleted))
and SUBSTRING ((SELECT update_ip from inserted), 1,7) <> ' 192.168 ')
Rollback

End
GO

So here's the question:

The condition is: when I pass the Uat field test, the path is used for 172.21.33.45 test and the IP is stored in the UPDATE_IP of the database table T_customer_info. Modify user profile Bank_number times wrong

Result: The operation tip Error "Thetransaction ended in the trigger. The batch has been aborted. "

Cause: IP is illegal, causing data rollback.

Later instead: if (((((select Bank_number from inserted) <> (select Bank_number from deleted))
or ((select Mobile_phone from inserted) <> (select Mobile_phone from deleted)
or ((select email from inserted) <> (select Mail from deleted))
and SUBSTRING ((SELECT update_ip from inserted), 1,6) <> ' 127.21 ')
Rollback

Normal update.

Note: Such triggers can prevent database clients from operating the database, and the local area network program modifies the database. It is mainly used for important database table information in production environment.

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.