Results 1 to 3 of 3

Thread: [RESOLVED] SQL 2008/2005 - Suspend Triggers

  1. #1

    Thread Starter
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Resolved [RESOLVED] SQL 2008/2005 - Suspend Triggers

    Does anyone know of a way to suspend triggers - without dropping them - from running when executing an insert from T-SQL?

    I've got a table that when inserted into fires off a trigger which populates another table. Under normal circumstances I'd be OK with that, but it's messing up later insert statements into that other table, and I need to be able to control the IDs (they are GUIDs so IDENTITY INSERT OFF/ON isn't an option). I need to be able to insert into this table, then the child/related table.

    I hate triggers...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: SQL 2008/2005 - Suspend Triggers

    For all triggers in a database:

    --Disable all triggers
    EXECUTE sp_msforeachtable "ALTER TABLE ? disable trigger all"
    --Enable all triggers
    EXECUTE sp_msforeachtable "ALTER TABLE ? enable trigger all"


    For 1 table
    --Disable
    Alter table tablename disable trigger all
    --Enable
    Alter table tablename enable trigger all
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: SQL 2008/2005 - Suspend Triggers

    Gary, that seemed to be what I needed/wanted... Originally I was under the impression that I would be able to do an alter table because of the architecture of the system and the security... but since this is going to be a well-documented one-off script I am creating (to be used as a template on future implementations) and will be run by us as the DBA (as opposed to some of our other scripts which can be run by the client) the permissions will not be a problem. Now I just need to script the data, get the pieces in the right order, and I should be good to go.

    thanks!

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

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