Skip to main content

Working on a software project can be time consuming and it is useful if any task could be shortened or automatized.

If you often work on SQL Server you might come across a requirement to disable or enable all triggers in database.

Here are instructions how you can achiveve that:

Disable all triggers in database

exec sp_msforeachtable @command1 = 'ALTER TABLE [table_name] DISABLE TRIGGER ALL'

Enable all triggers in database

exec sp_msforeachtable @command1 = 'ALTER TABLE [table_name] ENABLE TRIGGER ALL'

Note: Keep in mind that the function sp_msforeachtable is not documented.

- Advertisement -
- Advertisement -