SQL Tips by Namwar Rizvi

August 20, 2007

ENABLE/DISABLE all triggers of all tables in one statement

Filed under: Shortcuts, Undocumented features, Utility Functions, tips — namwar @ 8:15 pm

Sometimes we need to disable triggers to perform some tasks. Disabling the trigger by going to each table is very tedious. Following is avery quick way of disabling all triggers on all tables of the given database in a single statement.

sp_msforeachtable “ALTER TABLE ? DISABLE TRIGGER all”

To enable all triggers, you can use following statement

sp_msforeachtable “ALTER TABLE ? ENABLE TRIGGER all”

Blog at WordPress.com.