Hi,
How can I check if there is trigger for one table, and if yes disable?
if ( there is trigger in cm_template = yes )
ALTERTABLE cm_template DISABLETRIGGER TRG_cm_template
else
do stuff...
Since I try disable one trigger in a table which there is not trigger I think I'll receive one error. am I right?
cheers,
If you are using 2005, this is really easy:
select object_name(parent_id) as table_name, name as trigger_name, is_disabled
from sys.triggers
For 2000, you can use:
SELECT OBJECT_NAME (parent_obj), name,
OBJECTPROPERTY (id, 'ExecIsTriggerDisabled') as is_disabled
FROM sysobjects
WHERE type = 'TR'
Credit: By Srinivas Sampath MCSE, MVP (SQL Server) in his article: http://sqljunkies.com/Article/F5783CE9-BA74-4657-BF9D-1139BCC3096B.scuk
sql
No comments:
Post a Comment