Is it possible to disable a Trigger for a particular type of transaction?
There are 2 transactions running A,B..I want the trigger to be disabled for Transaction 'A' but enable it for 'B',even if they are running at the same time?Not directly
--BY SP
if COLUMNS_UPDATED()>0 and 0<trigger_nestlevel(object_id('SP Name')) return
if @.@.rowcount=0 return
if exists(select 'x' from inserted) and 0<trigger_nestlevel(object_id('SP Name')) return
if exists(select 'x' from deleted ) and 0<trigger_nestlevel(object_id('SP Name')) return
--BY TABLE
IF COLUMNS_UPDATED()>0 begin
if exists(select 'x' from YourTable where Id=object_name(@.@.procid) and Op='U') return
end else begin
if @.@.rowcount=0 return
if exists(select 'x' from inserted) and exists(select 'x' from YourTable where Id=object_name(@.@.procid) and Op='I') return
if exists(select 'x' from deleted ) and exists(select 'x' from YourTable where Id=object_name(@.@.procid) and Op='D') return
end
Good luck !
2012年2月19日星期日
disable trigger
标签:
database,
disable,
disabled,
microsoft,
mysql,
oracle,
particular,
running,
server,
sql,
transactions,
transactionthere,
trigger,
type
订阅:
博文评论 (Atom)
没有评论:
发表评论