- Blog - http://blog.bennett-scharf.com -
Trigger Mass Enable / Disable
Posted By Bennett On 29. July 2009 @ 11:12 In T-SQL | No Comments
Pretty trivial, really:
SELECT ‘ALTER TABLE ‘ + OBJECT_NAME(PARENT_ID) + ‘ ENABLE TRIGGER ‘ + [NAME]
FROM sys.triggers
…add a where clause if needed. Paste the output back into the query window and modify as needed. You can also slap some code around it to generate some dynamic SQL like this:
DECLARE @SQL VARCHAR(MAX)
SELECT @SQL=COALESCE(@SQL,”)+ ‘ALTER TABLE ‘ + OBJECT_NAME(PARENT_ID) + ‘ ENABLE TRIGGER ‘ + [NAME] + ‘; ‘
FROM sys.triggers
PRINT @SQL
Article printed from Blog: http://blog.bennett-scharf.com
URL to article: http://blog.bennett-scharf.com/2009/07/29/trigger-mass-enable-disable/
Click here to print.