Writing a generic audit trail trigger in SQL Server

How do you write an audit trail trigger in SQL Server 2000? I want to keep track of inserts, deletes and updates of all of the tables in a particular database.

    Requires Free Membership to View

Writing a generic audit trail trigger in SQL Server can be a bit tricky, as it requires manipulation of a bitmask exposed by the COLUMNS_UPDATED function. You'll also need to figure out how to store disparate data types in some generic fashion, which might be difficult if your database uses TEXT, NTEXT, or IMAGE columns.

Luckily, SQL Server MVP Nigel Rivett has already done most of the work. You can find his audit trigger at Nigel's Web site.

This was first published in May 2006

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.