Home All Groups Group Topic Archive Search About

Can a trigger be inadvertantly disabled?



Author
3 Dec 2008 9:20 PM
JoelB
A customer reported some odd behavior, and it turned out to be because a
trigger was disabled.  Access to the SQL Server is quite limited, and it
seems very unlikely that anyone intentionally disabled this trigger.

Is there any way---like if the system has a problem with the trigger or
something---that a trigger can become disabled?  Or is the only way through
deliberate and specific human action?

Also, is there a quick way to see whether any other triggers in a database
are disabled?

TIA,
  Joel

Author
3 Dec 2008 9:30 PM
Norman Yuan
It is possible in a SP execution, the code in the SP needs to disable some
table's trigger, does something, then enable the trigger back at the end of
execution. Now, if the SP's execution did not finish for some reason, the
disabled trigger would be left disabled.


Show quoteHide quote
"JoelB" <Jo***@discussions.microsoft.com> wrote in message
news:B7DEB15C-F0FB-4121-997B-A493E390A3DD@microsoft.com...
>A customer reported some odd behavior, and it turned out to be because a
> trigger was disabled.  Access to the SQL Server is quite limited, and it
> seems very unlikely that anyone intentionally disabled this trigger.
>
> Is there any way---like if the system has a problem with the trigger or
> something---that a trigger can become disabled?  Or is the only way
> through
> deliberate and specific human action?
>
> Also, is there a quick way to see whether any other triggers in a database
> are disabled?
>
> TIA,
>  Joel
Are all your drivers up to date? click for free checkup

Author
3 Dec 2008 9:43 PM
JoelB
Norman,

I'm confident that that's not what took place in this instance, as we don't
have any SPs that take advantage of DISABLE TRIGGER.  Thanks for the
information though---it's good to know.

Joel

Show quoteHide quote
"Norman Yuan" wrote:

> It is possible in a SP execution, the code in the SP needs to disable some
> table's trigger, does something, then enable the trigger back at the end of
> execution. Now, if the SP's execution did not finish for some reason, the
> disabled trigger would be left disabled.
>
>
> "JoelB" <Jo***@discussions.microsoft.com> wrote in message
> news:B7DEB15C-F0FB-4121-997B-A493E390A3DD@microsoft.com...
> >A customer reported some odd behavior, and it turned out to be because a
> > trigger was disabled.  Access to the SQL Server is quite limited, and it
> > seems very unlikely that anyone intentionally disabled this trigger.
> >
> > Is there any way---like if the system has a problem with the trigger or
> > something---that a trigger can become disabled?  Or is the only way
> > through
> > deliberate and specific human action?
> >
> > Also, is there a quick way to see whether any other triggers in a database
> > are disabled?
> >
> > TIA,
> >  Joel
>
>
Author
3 Dec 2008 10:29 PM
Vern Rabe
This will tell you all triggers that are disabled:

SELECT o.[name] AS [Trigger],
   OBJECT_NAME(o.parent_object_id) AS [Table]
   FROM sys.objects o
   WHERE o.[type] = 'TR'
   AND OBJECTPROPERTY(o.[object_id], 'ExecIsTriggerDisabled') = 0;

HTH
Vern Rabe

Show quoteHide quote
"JoelB" wrote:

> A customer reported some odd behavior, and it turned out to be because a
> trigger was disabled.  Access to the SQL Server is quite limited, and it
> seems very unlikely that anyone intentionally disabled this trigger.
>
> Is there any way---like if the system has a problem with the trigger or
> something---that a trigger can become disabled?  Or is the only way through
> deliberate and specific human action?
>
> Also, is there a quick way to see whether any other triggers in a database
> are disabled?
>
> TIA,
>   Joel
Author
3 Dec 2008 10:40 PM
Erland Sommarskog
JoelB (Jo***@discussions.microsoft.com) writes:
> A customer reported some odd behavior, and it turned out to be because a
> trigger was disabled.  Access to the SQL Server is quite limited, and it
> seems very unlikely that anyone intentionally disabled this trigger.
>
> Is there any way---like if the system has a problem with the trigger or
> something---that a trigger can become disabled?  Or is the only way
> through deliberate and specific human action?

The only way for a trigger to be disabled is through the execution of
ALTER TABLE DISABLE TRIGGER, one way or another.

> Also, is there a quick way to see whether any other triggers in a database
> are disabled?

SELECT name AS "trigger", object_id(parent_id) AS "table"
FROM   sys.triggers
WHERE  is_disabled = 1


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
3 Dec 2008 10:48 PM
Vern Rabe
Yes, much simpler than my solution.

Vern Rabe

Show quoteHide quote
"Erland Sommarskog" wrote:

> JoelB (Jo***@discussions.microsoft.com) writes:
> > A customer reported some odd behavior, and it turned out to be because a
> > trigger was disabled.  Access to the SQL Server is quite limited, and it
> > seems very unlikely that anyone intentionally disabled this trigger.
> >
> > Is there any way---like if the system has a problem with the trigger or
> > something---that a trigger can become disabled?  Or is the only way
> > through deliberate and specific human action?
>
> The only way for a trigger to be disabled is through the execution of
> ALTER TABLE DISABLE TRIGGER, one way or another.

> > Also, is there a quick way to see whether any other triggers in a database
> > are disabled?

> SELECT name AS "trigger", object_id(parent_id) AS "table"
> FROM   sys.triggers
> WHERE  is_disabled = 1
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
>
Author
3 Dec 2008 10:56 PM
JoelB
Well thank you both---that was just what I needed!  (although Vern, I used
yours before Erland's post, and had to change the zero to a one...after that
it worked great).

Thanks also Erland for the definitive answer on how they can be disabled. 
It was the only one that was disabled, and it remains a mystery as to how it
happened.

Thanks all for your help.

Joel

Show quoteHide quote
"Vern Rabe" wrote:

> Yes, much simpler than my solution.
>
> Vern Rabe
>
> "Erland Sommarskog" wrote:
>
> > JoelB (Jo***@discussions.microsoft.com) writes:
> > > A customer reported some odd behavior, and it turned out to be because a
> > > trigger was disabled.  Access to the SQL Server is quite limited, and it
> > > seems very unlikely that anyone intentionally disabled this trigger.
> > >
> > > Is there any way---like if the system has a problem with the trigger or
> > > something---that a trigger can become disabled?  Or is the only way
> > > through deliberate and specific human action?
> >
> > The only way for a trigger to be disabled is through the execution of
> > ALTER TABLE DISABLE TRIGGER, one way or another.
> > 
> > > Also, is there a quick way to see whether any other triggers in a database
> > > are disabled?
> > 
> > SELECT name AS "trigger", object_id(parent_id) AS "table"
> > FROM   sys.triggers
> > WHERE  is_disabled = 1
> >
> >
> > --
> > Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
> >
> > Links for SQL Server Books Online:
> > SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> > SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> > SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
> >
> >
Author
4 Dec 2008 3:00 PM
Damien
By default triggers do not fire during a bcp or BULK INSERT.

Show quoteHide quote
"JoelB" wrote:

> Well thank you both---that was just what I needed!  (although Vern, I used
> yours before Erland's post, and had to change the zero to a one...after that
> it worked great).
>
> Thanks also Erland for the definitive answer on how they can be disabled. 
> It was the only one that was disabled, and it remains a mystery as to how it
> happened.
>
> Thanks all for your help.
>
> Joel
>
> "Vern Rabe" wrote:
>
> > Yes, much simpler than my solution.
> >
> > Vern Rabe
> >
> > "Erland Sommarskog" wrote:
> >
> > > JoelB (Jo***@discussions.microsoft.com) writes:
> > > > A customer reported some odd behavior, and it turned out to be because a
> > > > trigger was disabled.  Access to the SQL Server is quite limited, and it
> > > > seems very unlikely that anyone intentionally disabled this trigger.
> > > >
> > > > Is there any way---like if the system has a problem with the trigger or
> > > > something---that a trigger can become disabled?  Or is the only way
> > > > through deliberate and specific human action?
> > >
> > > The only way for a trigger to be disabled is through the execution of
> > > ALTER TABLE DISABLE TRIGGER, one way or another.
> > > 
> > > > Also, is there a quick way to see whether any other triggers in a database
> > > > are disabled?
> > > 
> > > SELECT name AS "trigger", object_id(parent_id) AS "table"
> > > FROM   sys.triggers
> > > WHERE  is_disabled = 1
> > >
> > >
> > > --
> > > Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
> > >
> > > Links for SQL Server Books Online:
> > > SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> > > SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> > > SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
> > >
> > >
Author
4 Dec 2008 11:03 PM
Erland Sommarskog
Damien (Dam***@discussions.microsoft.com) writes:
> By default triggers do not fire during a bcp or BULK INSERT.

But running BCP or BULK INSERT does not disable the trigger for everyone.
--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
3 Dec 2008 10:55 PM
Vern Rabe
but I think you meant "object_name", not "object_id"

Vern Rabe

Show quoteHide quote
"Erland Sommarskog" wrote:

> JoelB (Jo***@discussions.microsoft.com) writes:
> > A customer reported some odd behavior, and it turned out to be because a
> > trigger was disabled.  Access to the SQL Server is quite limited, and it
> > seems very unlikely that anyone intentionally disabled this trigger.
> >
> > Is there any way---like if the system has a problem with the trigger or
> > something---that a trigger can become disabled?  Or is the only way
> > through deliberate and specific human action?
>
> The only way for a trigger to be disabled is through the execution of
> ALTER TABLE DISABLE TRIGGER, one way or another.

> > Also, is there a quick way to see whether any other triggers in a database
> > are disabled?

> SELECT name AS "trigger", object_id(parent_id) AS "table"
> FROM   sys.triggers
> WHERE  is_disabled = 1
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
>

Bookmark and Share