USE [ Datenbank]
GO
DECLARE @TriggerName AS VARCHAR(500)
-- Löschen oder Löschen aller Trigger in einer Datenbank in SQL Server
DECLARE DropTrigger CURSOR FOR
SELECT TRG .name AS TriggerName
FROM sys.triggers TRG
INNER JOIN sys.tables TBL
ON TBL.OBJECT_ID =TRG.parent_id
OPEN DropTrigger
FETCH Next FROM DropTrigger INTO @TriggerName
WHILE @@FETCH_STATUS =0
BEGIN
DECLARE @SQL VARCHAR(MAX)=NULL
SET @SQL='Drop Trigger ' + @TriggerName
PRINT 'Trigger ::' + @TriggerName
+ ' Dropped Successfully'
EXEC (@SQL)
PRINT @SQL
FETCH Next FROM DropTrigger INTO @TriggerName
END
DropTrigger SCHLIESSEN
DropTrigger DEALLOCATE