Created
May 11, 2021 12:40
-
-
Save bahadirdogru/bf639f5a79c953b0bb77b79a22b33ed4 to your computer and use it in GitHub Desktop.
Get enable and disable trigger list of databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t2.[name] TableTriggerReference | |
, SCHEMA_NAME(t2.[schema_id]) TableSchemaName | |
, t3.[rowcnt] TableReferenceRowCount | |
, t1.[name] TriggerName | |
, 'ALTER TABLE ' + SCHEMA_NAME(t2.schema_id) + '.' + t2.[name] + ' DISABLE TRIGGER ' + t1.[name] + ';' DisableScript | |
, 'ALTER TABLE ' + SCHEMA_NAME(t2.schema_id) + '.' + t2.[name] + ' ENABLE TRIGGER ' + t1.[name] + ';' EnableScript | |
, t1.object_id | |
,t1.is_disabled | |
FROM sys.triggers t1 | |
INNER JOIN sys.tables t2 ON t2.object_id = t1.parent_id | |
INNER JOIN sys.sysindexes t3 On t2.object_id = t3.id | |
WHERE | |
t1.is_ms_shipped = 0 | |
AND t1.parent_class = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment