SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

A Simply way to implement Audit Trail in SQL 2005

By huang_xiaodi, 2007/09/20

Total article views: 210 | Views in the last 30 days: 34

In a recent project, I need to record audit trail for some tables (for Insert, Update and Delete).
Using SQL 2005's XML datatype and the XML support it is very covenienet to use triggers to perform the audit trail requirement.
I create one table (Table_Audit)  to hold all audit trial data.
One stored procedure is created to generate the triggers for desired table.
The syntax to call the stored procedure is: EXEC dbo.USPU_Generate_Audit_Trigger ( 'tablename').
The trigger will do all the Audit work for you then.
If you need to deal with existing triggers, you may have to use sp_settriggerorder to set the execution order for those triggers and let the audit trigger fired last.

Author: Bill Huang
Company: Neurocomp Systems, Inc.
Date Submited: 09/20/2007

By huang_xiaodi, 2007/09/20

Total article views: 210 | Views in the last 30 days: 34
Your response
 
 
Related tags
 
Like this? Try these...

Column Level Permissions

By Mani Singh | Category: T-SQL
(not yet rated) | 30 reads

The Back Door DBA

By Brad M. McGehee | Category: Editorial
(not yet rated) | 210 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com