• Home /
  • Blog /
  • How to add audit trigger on a list of tables
Sql Server Tutorials

How to add audit trigger on a list of tables

For audit purpose you may be requested to add ModifyDate and ModifyBy columns for all your tables and create an audit trigger to automatically update that columns as soon as record was updated or inserted.

It is very easy to implement when you have one or two tables, but with 20-30 tables it may take time. But this task can be automated.

In the following script a temporary table created which will contain list of all tables required audit, and later table name and primary key name will be used for new column creation and creation of audit trigger on each table.

Comments

Yaplex - Freelance developer - white logo on black background

Yaplex is an IT Consulting and .NET development company co-founded by freelance developer Alex Shapovalov who lives in Canada and provides software development services in Canada, USA and all over the world.

Contact Information

Toronto, Canada
Phone: +1 647 328 3809
Email: alex@yaplex.com