News  
  By label  
  By team  
  By product  

ApexSQL Blog

Product announcements, promotions and other ApexSQL news


ApexSQL Audit trigger management features

The main components of ApexSQL Audit are generated SQL triggers that capture and store changed data by insert, update and delete SQL statements

ApexSQL Audit has a variety of interface features to allow viewing and managing of existing triggers including the ability to:
  • Filter or sort in various ways for reviewing by table name, status, type (Insert, Update or Delete statement auditing) or by schema
  • Disable or enable by selection
  • Delete by selection or all at once
  • Generate trigger DDL scripts

Main interface grid trigger management
The main grid can be used to review tables and audit triggers. All tables of a particular database, with or without ApexSQL Audit generated triggers, are shown on the main grid

Tables and their trigger types can be filtered and reviewed via the main grid’s Filter row

Main interface grid

If unaudited tables need reviewing, set the Audited field of the Filter row to (false)

Main grid filter example

To find all tables which are audited for insert, but not for updates, set the Filter row like this:
  • Insert field to True
  • Update field to False
  • Audited field to (true)

Main grid filter example

Trigger management module
Similarly, ApexSQL Audit provides a module which offers a quick trigger overview and basic trigger management functions. To access it select the Audit tab on the main toolbar, and click the Manage audit triggers button

Manage audit triggers button location

This option opens a dialog showing all triggers generated by ApexSQL Audit for a particular database. Unaudited tables will not be shown

Manage audit triggers dialog

Triggers can be enabled, disabled or deleted using this dialog

When disabled, a trigger is still an object in SQL Server, but isn’t fired. This provides a quick and easy way to turn auditing On/Off without having to delete objects

The Script option generates a SQL script for all or just a set of selected triggers

The Manage audit triggers dialog provides an overview of the generated triggers, their type and status. Any grid column can be filtered via the Filter row

To find all triggers that audit INSERT statement on the Person schema set the Filter row like this:

Manage audit triggers filter example

The Delete auditing dialog
All ApexSQL Audit triggers can easily be deleted using the Delete auditing dialog. To open this dialog select the Audit tab on the main toolbar, and click the Delete auditing button

Delete audititing button location

This button opens the Delete auditing dialog which provides options for deleting both the audit architecture (tables, views and procedures) and all audit triggers. Select the Delete audit triggers option to delete all generated triggers and confirm it with the Run button

Delete audititing dialog

This is easier than deleting all triggers using Manage audit triggers, since they do not have to be loaded for a preview and selected prior to deletion

The script to delete triggers manually
If none of the described UI options work for you, triggers can be deleted manually by executing the following SQL:

Use {DatabaseName}
Declare @trgName varchar(500) 
Declare cur Cursor For Select [name] From sys.triggers where type = 'tr' and name like 'tr___AUDIT%'
Open cur 
Fetch Next From cur Into @trgName 
While @@fetch_status = 0 
Begin 
Exec('Drop trigger ' + @trgName) 
Fetch Next From cur Into @trgName 
End
Close cur 
Deallocate cur


The 'tr___AUDIT%' string narrows the selection down to ApexSQL Audit triggers only


Labels: ,