The trigger--it's all my understanding of the trigger.
When you do the INSERT, delete, and so on, do some extra work,
For example, adding new data to the inserted table when it is added
Write an example
Insert into UserInfo (Name) output inserted. Id value (' Zhao Liu ')
He will return the ID of the currently inserted data
For example: INSERT INTO A (name,info) output inserted.id values (' Chen Zhi ', ' Shanxi ')
Explain the syntax of the trigger:
Create trigger trigger name on table name
for (after) | instead of [Insert,update,delete]
As
Begin
SQL script
End
Note that if you use for or after to represent the SQL script in the trigger after the [Insert,update,delete] operation has completed or before, and instead of the action replaces the operation with the SQL script in the trigger.
Specific usage:
Create Trigger Gettable on A
Instead of insert
As
Begin
SELECT * FROM A
End
And there is:
Create Trigger Gettable on A
For insert
As
Begin
SELECT * FROM A
End
Simple usage of SQL Server triggers