> For the complete documentation index, see [llms.txt](https://knowledgebase.qommentary.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.qommentary.com/qommentary-writeback/advanced/audit-trails/enable-audit-trails-for-database/sql-server-example.md).

# SQL Server example

This section shows how to set up audit trails for a SQL Server table.

The following Customers table will be used as a writeback destination table.

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCqVw2Dr_T1zAobWKU%2Fimage.png?alt=media&amp;token=a9403367-5289-4140-a711-7074f2c2f54e" alt=""></div>

{% hint style="success" %}
This example assumes that you already have an existing extension using the Customers table as the destination table
{% endhint %}

To enable audit trails for the Customers table:

1\. Create a new table *Customers\_log* with the same structure as the writeback destination table and add the extra auditing columns

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCr-54zRYwY1icmSkE%2Fimage.png?alt=media&amp;token=4a7f7a1b-d27e-4aa2-8f54-3d36523e9caf" alt=""></div>

{% hint style="warning" %}
Note that the Id column (customer id) is not a primary key on this table since it will be duplicated on the *Customers\_log* table. If you want to assign an id for each audit row, you can add a RowId column and set it as an identity column.
{% endhint %}

2\. Go to the writeback extension in Qlik sense and enable logs

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCzn1GMNA9Nh6i8Fy6%2F-MZD-99y6zu51JdErEHw%2Fimage.png?alt=media&amp;token=9aba0baa-f947-4673-ba6f-931b736b5280" alt=""></div>

3\. Enter *Customers\_log* as the Audit log table name

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCuDPsOCjzuWrTsLmS%2Fimage.png?alt=media&amp;token=4720a6a5-edf1-4b89-a4e4-e78f7d80867a" alt=""></div>

4\. Go to your writeback extension, add a record and click on Save.

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCwn5OvP7MArcpdrPW%2Fimage.png?alt=media&amp;token=07e2909f-fd63-4254-9a97-dd83eec4e2a8" alt=""></div>

5\. Edit the existing record and click on Save

![](https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCxAolRq3Ux07aCsjC%2Fimage.png?alt=media\&token=0e93dc8b-a4f9-44c1-b938-f07e370a792b)

6\. Open the Customers\_log table

<div align="left"><img src="https://1677646431-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M43RhGzV8Plu0tfknia%2F-MZCoD3-NJFITNHta0Pi%2F-MZCxgQ5ne8DZ4TAtYGj%2Fimage.png?alt=media&amp;token=8e0fe1da-c813-42d9-8985-cc64eaf4a3c3" alt=""></div>

As you can see from the Customers\_log screenthost, Qommentary audits all changes made by users.
