13 December,2012 by Tom Collins
I use these two methods to return a list of TRIGGERS for a SQL Server database. Sometimes I need to just return a list of TRIGGERS for a specific table - where I add an extra predicate to return a TRIGGER list just for a table
Method 1 – uses the view sys.triggers. The sys.triggers view returns DML and DDL triggers. The view returns SQL Triggers and Assembly Triggers
Method 2 – shows only DML triggers , as they are schema scoped, and sysobjects returns only schema scoped objects.
--Method 1 select object_name(parent_id) as [Table_name],object_name(object_id) as [Trigger_Name] from sys.triggers --Method 2 SELECT DISTINCT SO.[name] AS [Table_name], TR.[name] AS [Trigger_name] FROM [sysobjects] as SO JOIN [sysobjects] as TR ON SO.[id] = TR.[parent_obj] WHERE TR.[type] = 'TR' --AND SO.[name] = ‘my_table’ ORDER BY [Table_name], [Trigger_name]
SQL Server – Delete SQL Logon TRIGGER syntax - SQL Server DBA
SQL Server – Restrict SQL Server Logons by IP with EVENTDATA ...
SQL Server recompile error after upgrade from 2000 to 2005
List Foreign Keys referencing tables in SQL Server
How to find all identity columns in SQL Server
How to find default values of all SQL Server columns
How to find computed columns on a SQL Server table
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |