问题描述:

On three different tables I have separate INSERT, UPDATE and DELETE triggers.

I know positively that they work as expected (tried adding, deleting, updating and confirmed the changes going to log-table). However, it happens that rows are removed or added, without my log tables having any content.

So my question is: Is it possible for instance to add a record without the enabled INSERT trigger being triggered?

This is on SQL Server 2005.

网友答案:

It is possible if queries were executed that disable the use of a particular trigger, e.g. by using

DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }
ON { object_name | DATABASE | ALL SERVER } [ ; ]

Also, as Damien pointed out, in may cases your trigger may only work on single records. Wrong (simplyfied example:

    UPDATE table SET field = value WHERE PK = (SELECT PK FROM inserted)

Better:

    UPDATE table SET field = value WHERE PK IN (SELECT PK FROM inserted)

Show us your trigger, and we'll figure it out.

相关阅读:
Top