TRIGER DISABLE VEYA ENABLE
Disable all the triggers for a single database:
USE AdventureWorks;GO
DISABLE TRIGGER Person.uAddress ONAdventureWorks;GO
Disable all the triggers for all servers:
USE AdventureWorks;GO
DISABLE TRIGGER ALL ON ALLSERVER;GO
sp_MSforeachtable "ALTER TABLE ? DISABLE TRIGGER ALL"
To Enable All the Triggers
sp_MSforeachtable "ALTER TABLE ? ENABLE TRIGGER ALL"
use MyDatabasesp_msforeachtable 'ALTER TABLE ? DISABLE TRIGGER all'To enable all triggers, you can use following statementuse MyDatabasesp_msforeachtable 'ALTER TABLE ? ENABLE TRIGGER all'
Disable or Enable all Triggers on a Table
If you need to bring a copy of the database from production to another environment, you may want to disable all the triggers for all tables. Here is a simple syntax you can use to accomplish this. First you could specify the specific table(s) for which you want to disable triggers.
The re-enable all triggers just use this syntax.ALTER TABLE [dbo].[MyTable] DISABLE TRIGGER ALL
Finally, if you don't want to specify the tables (perhaps because you have triggers on many tables) then just use sp_msforeachtable.ALTER TABLE [dbo].[MyTable] ENABLE TRIGGER ALL
EXEC sp_msforeachtable "ALTER TABLE ? DISABLE TRIGGER ALL"
Hiç yorum yok