Auto generate SQL audit tables and database triggers

Wed, Nov 28, 2012 One-minute read

One approach to monitoring version history of items in SQL tables is to use an _Audit table version with database triggers. However, the creation and maintenance of the tables and triggers can be time consuming. This post provided a nice script to automate the creation but unfortunately it suffered a few issues. In the comments, someone posted a sproc version of the script - but unfortunately this was also broken.

So I have tidied it up and fixed the issues. My host doesn’t let me post SQL in these posts, so you can view the file here.

You can then execute the sproc with the name of your table, and it will do the rest. Enjoy.