Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---Disable Triggers
- DECLARE table_cursor CURSOR
- FOR SELECT TABLE_SCHEMA, TABLE_NAME
- FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE <> 'VIEW'
- DECLARE @table_schema nvarchar(2000), @table_name nvarchar(2000)
- OPEN table_cursor
- FETCH NEXT FROM table_cursor
- INTO @table_schema, @table_name
- WHILE @@FETCH_STATUS = 0
- BEGIN
- DECLARE @sql nvarchar(2000)
- SET @sql = 'ALTER TABLE ' + @table_schema + '.[' + @table_name + '] DISABLE TRIGGER all'
- PRINT @sql
- EXEC (@sql)
- FETCH NEXT FROM table_cursor
- INTO @table_schema, @table_name
- END
- CLOSE table_cursor
- DEALLOCATE table_cursor
- ---Enable Triggers
- DECLARE table_cursor CURSOR
- FOR SELECT TABLE_SCHEMA, TABLE_NAME
- FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE <> 'VIEW'
- DECLARE @table_schema nvarchar(2000), @table_name nvarchar(2000)
- OPEN table_cursor
- FETCH NEXT FROM table_cursor
- INTO @table_schema, @table_name
- WHILE @@FETCH_STATUS = 0
- BEGIN
- DECLARE @sql nvarchar(2000)
- SET @sql = 'ALTER TABLE ' + @table_schema + '.[' + @table_name + '] ENABLE TRIGGER all'
- PRINT @sql
- EXEC (@sql)
- FETCH NEXT FROM table_cursor
- INTO @table_schema, @table_name
- END
- CLOSE table_cursor
- DEALLOCATE table_cursor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement