Refactoring «Introduce Trigger for History»

The primary reason you would apply Introduce Trigger for History is to delegate the tracking of data changes to the database itself. This strategy ensures that if any application modifies critical source data, the change will be tracked or audited.

To apply Introduce Trigger for History, you need to do the following:

  1. Select table in Object Explorer

  2. Right click on the selected table and then choose SQL Refactor Studio -> Introduce Trigger For History… menu command.

  3. Determine what columns to collect history for and then press the Next button.

  4. Enter the name of the history table and the name of the trigger.

  5. Specify the data modification statements (INSERT, UPDATE, DELETE) that activate the trigger.

  6. Press the Finish button to generate the SQL code.

  7. Modify generated code if you need and press the F5 to create objects.