T-SQL: Trigger – INSERT AFTER

Initiating actions in response to events.

One of the new features provided with SQL Server 2005 enables actions to be performed after an event occurs on an object, in this case the “people” table.

1-t-sql-insert-after

To illustrate an “after” response, the following code creates a trigger that responds to a new record being created.
When a new record is created, the “trigger_action” field is updated for that new record with the first name of the person and the total number of records in the table including the newly created record.

2-t-sql-insert-after

With this newly created record, you can see the first name ‘h’ and that there is now “14” records in the table.

3-t-sql-insert-after

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s