Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to check whether trigger is disabled or not in all database in one shot in sql..?
Posted
Comments
King Fisher 27-May-15 7:06am    
...
Thanks7872 27-May-15 8:32am    
What do you mean by one shot? Why you want to check this? What are you trying to do? This is not a social networking. You have to explain issue properly in order to have a reasonable answer.

This query will help you


SQL
SELECT *
FROM sys.triggers


OR

SQL
SELECT
       TAB.name as Table_Name
     , TRIG.name as Trigger_Name
     , TRIG.is_disabled  --or objectproperty(object_id('TriggerName'), 'ExecIsTriggerDisabled')
FROM [sys].[triggers] as TRIG
inner join sys.tables as TAB
on TRIG.parent_id = TAB.object_id


for finding Disabled trigers in all databases in a server

SQL
you can use sp_MSforeachdb for this purpose like

DECLARE @command varchar(1000)
SELECT @command = 'USE ? SELECT (SELECT DB_NAME()),* FROM sys.triggers WHERE is_disabled = 1'
EXEC sp_MSforeachdb @command
 
Share this answer
 
v3
Comments
Member 11337367 27-May-15 7:26am    
I want to check in all database in one shot..
kashif Atiq 27-May-15 7:40am    
so what is the problem with these two queries? they will return you statuses of all the triggers in whole database
Member 11337367 27-May-15 8:14am    
I want to change database name each time but i dont want to do like that ..it should return all disabled trigger from all database..
kashif Atiq 27-May-15 8:40am    
you can use sp_MSforeachdb for this purpose like

DECLARE @command varchar(1000)
SELECT @command = 'USE ? SELECT (SELECT DB_NAME()),* FROM sys.triggers WHERE is_disabled = 1'
EXEC sp_MSforeachdb @command
Please try to use below query. That will return whether the trigger is disabled or not.

SQL
select * from sys.triggers where is_disabled = 1


Please let me know if you have any concern or query.

Thanks
Advay Pandya
 
Share this answer
 
 
Share this answer
 
use sys.triggers with msforeachdb

try this link[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900