求:批量删除触发器的方法
请问:有什么语句可以批量删除数据库中的触发器?
[解决办法]
上面写的代码中不应该有xtype,那是针对SQLServer的,可以这么写:
declare @TriggerName nvarchar(128)
declare mycursor cursor
for
select name from sysobjects where type= 'TR ' and status> 0
open mycursor
fetch next from mycursor into @TriggerName
while(@@fetch_status=0)
begin
exec( 'if exists (select * from sysobjects where name = ' + @TriggerName + ' and type= ' 'TR ' ') drop trigger ' + @TriggerName)
fetch next from mycursor into @TriggerName
end
close mycursor
deallocate mycursor