Created
January 13, 2012 01:48
-
-
Save jaredmdobson/1604201 to your computer and use it in GitHub Desktop.
T-SQL Enable All Triggers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[EnableAllTriggers] | |
AS | |
DECLARE @string VARCHAR(8000) | |
DECLARE @tableName NVARCHAR(500) | |
DECLARE cur CURSOR | |
FOR SELECT name AS tbname FROM sysobjects WHERE id IN(SELECT parent_obj FROM sysobjects WHERE xtype='tr') | |
OPEN cur | |
FETCH NEXT FROM cur INTO @tableName | |
WHILE @@fetch_status = 0 | |
BEGIN | |
SET @string = 'Alter table ' + @tableName + ' Enable trigger all' | |
EXEC (@string) | |
FETCH NEXT FROM cur INTO @tableName | |
END | |
CLOSE cur | |
DEALLOCATE cur | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment