I have an update trigger that updates some important status fields in a table tblCurrent
.
When I first upload the daily batch of records into tblCurrent
(circa 10K records), I perform some UPDATEs via three separate stored procedures when these are first uploaded and only then.
How can I prevent the update trigger from running during these three initial UPDATEs?
An INSTEAD OF trigger is an SQL trigger that is processed “instead of” an SQL UPDATE, DELETE or INSERT statement. Unlike SQL BEFORE and AFTER triggers, an INSTEAD OF trigger can be defined only on a view, not a table.
Without using any WHERE clause, the SQL UPDATE command can change all the records for the specific columns of the table.
A DELETE does not fire UPDATE triggers. If you have a trigger defined to be fired on DELETE and also on UPDATE then it will be executed on a DELETE but that's because it's also a DELETE trigger.
You could temporary disable triggers for the table and then enable them back. MSDN article.
DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL SERVER } [ ; ]
ENABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL SERVER } [ ; ]
For example to disable all triggers for given table run following statement:
DISABLE TRIGGER ALL ON tblCurrent;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With