"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Tuesday, October 12, 2010

Enable and disable Trigger in SQL Server

Disable Triggers instead of dropping them.
================================

Business rules in table often expect your application to update the table one row at a time. Also some triggers generate error when the code in the trigger assigns to a local variable returned by selecting a column from the inserted virtual table. The assignment fails if you are updating multiple rows because the inserted table contains more than one row so the sub query returns more than a single value. Multiple updates need special handling in such scenario. Developers often wind up dropping a trigger before multi- row updates then creating them later.

But this scenario can be overcome by disabling trigger

Alter Table Mytable Disable Trigger mytrigger

You can enable Trigger using
Alter Table Mytable Enable Trigger mytrigger
Have a nice day... 'N happy Coding :)

No comments: