Results 1 to 2 of 2

Thread: SQL (triggers)

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    Greece
    Posts
    12

    Question SQL (triggers)

    The problem that i have is that i want to disable a trigger of a table on an SQL SERVER 7.0 for a small period of time and then to enable it again. How can i do it?

  2. #2
    pvb
    Guest
    This was posted by Brian Knight on SQLServerCentral.com in a script entitled "Quickly Enable/Disable Triggers and Constraints"(for reference):
    Code:
    sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
    sp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER  all"
    
    /*
    To enable them back, you can reverse the function. Let's get a 
    little more creative this time. We'll explicitly set the parameters 
    and list each table before enabling them so we can verify any 
    errors easily.
    */
    
    sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? CHECK CONSTRAINT all"
    sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? ENABLE TRIGGER  all"
    http://www.sqlservercentral.com/scri...sp?scriptid=25

    BOL also explains how to do this if you look up triggers and alter table syntax

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width