Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Modification to Automate Audit Trigger Generation

By Robert N,

This is a modification to Automate Audit Trigger Generation at http://www.sqlservercentral.com/scripts/contributions/1073.asp by walkerjet. The changes were made to accommodate tables using different types for their primary keys, (i.e. int, smallint, char, etc.), add the ModifiedById and DTStamp columns, exclude legacy tables that do not have a primary key defined, exclude fields of type text, ntext, and image from the script generation. Finally enclose the entire script in BEGIN TRAN and COMMIT TRAN with a MARK.

The single point of entry is to execute the vp_GenerateTriggers.

Parameters are Table Name and Action. Table name can be any table or 'ALL'
for all tables. Action can be I, U, D - you guessed it and A for all.

So execute vp_GenerateTriggers 'ALL', 'A' will generate insert update and delete triggers for all tables in the database.

Total article views: 334 | Views in the last 30 days: 1
 
Related Articles
FORUM

Generate Insert script

Generate Insert script

FORUM

Generate Script File Name

Generate Script File Name

SCRIPT

Generated script to update statistics

Generated script to update statistics

FORUM

Generate scripts for all databases

Generate scripts for all databases

ARTICLE

A Standard Database Security Script Generator

A script generator for standard security compliance.

Tags
t-sql    
 
Contribute