Deshabilitar todos los triggers de una base de datos - SQL Server.
El comando para deshabilitar todos los triggers de una base de datos es..
Print 'Disabling all Trigger'
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
o tambien
CREATE Procedure [dbo].[DisableAllTriggers]
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 + ' Disable trigger all'
exec (@string)
Fetch next from cur into @tableName
end
close cur
deallocate cur
Exec [dbo].[DisableAllTriggers]
Print 'Disabling all Trigger'
exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
o tambien
CREATE Procedure [dbo].[DisableAllTriggers]
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 + ' Disable trigger all'
exec (@string)
Fetch next from cur into @tableName
end
close cur
deallocate cur
Exec [dbo].[DisableAllTriggers]
Este es un POST para no perder tiempo buscando la próxima vez que tenga que hacerlo.
bien pelao
ResponderBorrarGracias por el aporte, saludos.
ResponderBorrargracias
ResponderBorrar