Results 1 to 2 of 2

Thread: disable trigger

  1. #1
    Join Date
    May 2002
    Location
    Timbaktu
    Posts
    185

    Unanswered: disable trigger

    Is it possible to disable a Trigger for a particular type of transaction?
    There are 2 transactions running A,B..I want the trigger to be disabled for Transaction 'A' but enable it for 'B',even if they are running at the same time?

  2. #2
    Join Date
    Dec 2002
    Location
    Czech Republic
    Posts
    249
    Not directly

    --BY SP
    if COLUMNS_UPDATED()>0 and 0<trigger_nestlevel(object_id('SP Name')) return
    if @@rowcount=0 return
    if exists(select 'x' from inserted) and 0<trigger_nestlevel(object_id('SP Name')) return
    if exists(select 'x' from deleted ) and 0<trigger_nestlevel(object_id('SP Name')) return

    --BY TABLE
    IF COLUMNS_UPDATED()>0 begin
    if exists(select 'x' from YourTable where Id=object_name(@@procid) and Op='U') return
    end else begin
    if @@rowcount=0 return
    if exists(select 'x' from inserted) and exists(select 'x' from YourTable where Id=object_name(@@procid) and Op='I') return
    if exists(select 'x' from deleted ) and exists(select 'x' from YourTable where Id=object_name(@@procid) and Op='D') return
    end

    Good luck !

Posting Permissions

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