Collections:
sys.sql_modules - Getting Trigger Definitions Back in SQL Server
How To Get the Definition of a Trigger Back in SQL Server?
✍: FYIcenter.com
If you want get the definition of an existing trigger back from the SQL Server, you can use the catalog view called sys.sql_modules, which stores definitions of views, stored procedures, and triggers.
The sys.sql_modules holds trigger definitions identifiable by the object id of each trigger. The tutorial exercise below shows you how to retrieve the definition of trigger, "dml_message" by joining sys.sql_modules and sys.triggers:
USE FyiCenterData;
GO
SELECT m.definition
FROM sys.sql_modules m, sys.triggers t
WHERE m.object_id = t.object_id
AND t.name = 'dml_message';
GO
definition
-------------------------------------------------
CREATE TRIGGER dml_message ON fyi_users
AFTER INSERT, UPDATE, DELETE
AS
PRINT 'Time: '+CONVERT(VARCHAR(12),GETDATE());
PRINT 'Records are inserted, updated,'
+ ' or deleted in fyi_users';
(1 row(s) affected)
⇒ "DISABLE TRIGGER" - Disabling Triggers in SQL Server
⇐ "DROP TRIGGER" - Deleting Existing Triggers in SQL Server
2016-10-24, 3024🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions I am new to Oracle database. Here is a list of f...
Can You Drop an Index Associated with a Unique or Primary Key Constraint in Oracle? You can not dele...
How To Create a Dynamic Cursor with the DYNAMIC Option in SQL Server Transact-SQL? If the underlying...
What Are the Underflow and Overflow Behaviors on FLOAT Literals in SQL Server Transact-SQL? If you e...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...