News
By label
By team
By product

ApexSQL Blog

Product announcements, promotions and other ApexSQL news


Trigger based SQL Server auditing – customize data tracking and reporting (part I)

ApexSQL Audit uses SQL Server database triggers for capturing and storing changes that occur on the audited data. More specifically, DML database triggers are used for capturing INSERT, UPDATE or DELETE statements. Now, since there are various types of columns in each database table, reading the audit report is often not very user friendly and this especially applies to foreign key values in different tables

For example, audited numeric fields, often used as reference keys and changes in those values, are reported in ApexSQL Audit’s reporting system with the Old and New value columns. That may be enough for someone who is aware of the exact data structure that is being audited, but for someone who just needs to read the report for i.e. business purposes, it definitely isn’t. Therefore, there are two ApexSQL Audit report enhancing features:
  • Watches
  • Lookups
Watches
ApexSQL Audit uses watches as additional “readable” table fields along with the information about audited changes, even if the watched field itself isn't changed. Watches allow adding recognizable fields to any audit database change, which is helpful to those reading the reports

Let’s say that some changes occurred in the Clients table, containing a list of contacts with their:
  • ClientID
  • Name
  • Email
  • and the Company name
If a contact name of a client company has been updated, for the initial report, it would not mean much to know only the old and new names. But if additional information, such as the company name is provided, that would make a difference

To accomplish that, the corresponding watch should be added. The Watches panel can be accessed from the View tab, in the Show panels section. In this case, to add a watch Company name with the audited contact Name:
  1. Select the Name field from the Audit field name drop-down menu

    Audit Field Name menu

  2. Select Company from the Watch field name drop-down menu

    Audit Watch Field Name menu

  3. Confirm the new watch by clicking the Add button
The created watch will provide additional company name information whenever a client’s name is changed

Any watch can be changed or deleted afterwards, but any previously stored information in the ApexSQL Audit SQL Server repository database will not be affected

Be advised that watches can only be used for values that are changed. Watches will not work for new values or deleted ones

As mentioned above, there is another advanced feature of ApexSQL Audit to create more human-readable reports

Labels: ,