This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12339|Reply: 0

[Source] sqlserver-trigger-determine which field was updated.

[Copy link]
Posted on 7/9/2018 5:05:47 PM | | | |
SQL script:




trigger statementsTwo special tables:d eleted and inserted tables.

The Deleted table is used to store copies of the rows affected by the DELETE and UPDATE statements. When you execute a DELETE or UPDATE statement, the row is removed from the trigger table and transferred to the deleted table. Deleted tables and trigger tables usually don't have the same rows.

The Inserted table is used to store copies of the rows affected by the INSERT and UPDATE statements. In an insert or update transaction, new rows are added to both the inserted and trigger tables. The rows in the Inserted table are copies of the new rows in the trigger table.

1. Insert operation
Inserted tables have data, deleted tables have no data

2. Delete
Inserted tables have no data, and deleted tables have data

3. Update
Inserted tables have data (new data), Deleted tables have data (old data)





Previous:The "Agent XP" component has been used as part of this server security configuration...
Next:IIS7 performance optimization
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com