NetInverse Developers Blog

March 8, 2009
Category: SQL — Tags: — admin @ 12:02 am

Normally you use the trigger functionality with Data Manipulation Language (DML) commands such as INSERT, UPDATE, and DELETE. Now SQL 2005 introduces new Data Definition Language (DDL) triggers. You can use it to audit schema changes.

Example of DDL Trigger:

    CREATE TRIGGER safety
    ON DATABASE
    FOR DROP_TABLE, ALTER_TABLE
    AS
    PRINT ‘You must disable Trigger “safety” to drop or alter tables!’
    ROLLBACK;

    DISABLE TRIGGER safety ON DATABASE;

Please refer to MSDN for details: MSDN: Designing DDL Triggers.
An articel about using DDL triggers: Using SQL Server 2005 to document Sarbanes-Oxley compliance

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

©2009 NetInverse. All rights reserved. Powered by WordPress