Create Triggers Dynamically

  • I need to create and drop triggers on specified table as and when the user turns auditing on and off for these tables.

    MSDN says that you may not use CREATE TRIGGER within a CREATE PROCEDURE.

    Any ideas on how to get round this ?

    Cheers

    Paul

  • No Worries I have used ,

    exec sp_executesql @sql

    where @sql contains the create trigger statement.

    Cheers

    Paul

  • Instead of deleting and recreating it why don't you just disable and reenable.

    ALTER TABLE <tablename> DISABLE TRIGGER <triggername>

    ALTER TABLE <tablename> ENABLE TRIGGER <triggername>

    cheers,

    Mike

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply