April 7, 2015 | Posted in: SQL Server, Uncategorized

declare @temp table
(table_name varchar(100), trigger_name varchar(100))
insert into @temp
select    object_name(parent_id), name
from    sys.triggers
where    name in
select object_name(object_id) from sys.sql_modules where definition like ‘%SEARCH%STRING%’
and is_disabled = 0

declare @sql varchar(255)

declare db_cursor cursor for
select ‘ALTER TABLE ‘ + table_name + ‘ DISABLE TRIGGER [' + trigger_name + ']‘ from @temp x

open db_cursor
fetch next from db_cursor into @sql

while @@FETCH_STATUS = 0

exec (@sql);

fetch next from db_cursor into @sql

close db_cursor
deallocate db_cursor

Be the first to comment.

Leave a Reply


20 + 17 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>