Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mobasha
Starting Member
45 Posts |
Posted - 2007-05-07 : 09:41:19
|
i have wrote a code to disable all the triggers on the database tablesand i want to get the information about the triggers current state,is there is any function or view that can help me out???and this is the code :create procedure disabling_trigger (@server varchar(50),@database varchar(50),@owner varchar(20))as declare @sqlstring varchar(1000)beginset @sqlstring=' declare curs_trigger cursor for select name from '+@server+'.'+@database+'.'+@owner+'.sysobjects where name not like ''dts%''and xtype=''u'' declare @table_name varchar(500)open curs_triggerfetch next from curs_trigger into @table_namewhile(@@fetch_status=0) begin declare @x varchar(1000) set @x=''alter table '' +@table_name+ '' disable trigger all'' exec (@x) fetch next from curs_trigger into @table_name endclose curs_triggerdeallocate curs_trigger'exec (@sqlstring)endMobashA |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-07 : 09:42:36
|
What do you mean by "state" of trigger?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2007-05-07 : 09:45:00
|
[code]selecttrigger_name = name,trigger_owner = user_name(uid),Is_Disabled = case when OBJECTPROPERTY(id, 'ExecIsTriggerDisabled') = 1 then 'Yes' else 'No' endfrom sysobjectswhere parent_obj = object_id(@objname) and type = 'TR'[/code]Chiraghttp://chirikworld.blogspot.com/ |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-07 : 09:53:24
|
Be sure to take a note of the issue with Disable Trigger here:[url]http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/10/27/1248.aspx[/url]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
mobasha
Starting Member
45 Posts |
Posted - 2007-05-07 : 13:06:01
|
thanks alot i think Chirag this is going to helpMobashA |
|
|
mobasha
Starting Member
45 Posts |
Posted - 2007-05-07 : 13:08:43
|
i mean by state is it disabled or enabledMobashA |
|
|
|
|
|