Dropping all Triggers

,

When implementing a pilot study of audit trail triggers, you often want a way of removing all triggers in the database in order to retest your scripts: here it is!

declare 	@name 	        varchar(500)
declare 	mycursor 	cursor
for
select name from sysobjects where type = 'tr'

open mycursor
fetch next from mycursor into @name

while @@fetch_status = 0
begin
	exec ('drop trigger ' + @name)
	select 'Deleted ' + @name
	fetch next from mycursor into @name
end
close mycursor
deallocate mycursor

Rate

Share

Share

Rate