禁用触发器两种写法

1)


 
  disable trigger all  on dbo.Part_Mobile--禁用触发器
go
update Part_Mobile
set
--select
verify_id=(
case when Count_NoExists>0 then 0
when Count_Error>0 then 1
when Count_Refuse>0 then 2
when Count_Busy>0 then 3
when Count_Correct>0 then 4 end
),
verify_dtm=isnull(verify_dtm,in_date)
--,*
 from Part_Mobile
where Count_NoExists+
Count_Error+Count_Refuse
+Count_Busy+Count_Correct>0
and Verify_ID=255
go
enable trigger all on dbo.Part_Mobile--启用触发器

 

2)

USE [SINO]
GO
/****** Object:  Trigger [dbo].[TR_CATI_insert_Test_Mobile]    Script Date: 12/02/2010 11:12:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[TR_CATI_insert_Test_Mobile]
   ON  [dbo].[Test_Mobile]
   AFTER insert
AS
BEGIN
 SET NOCOUNT ON;
    if exists(select * from inserted where 是CATI=1)
    begin
    alter table Item_Insurance..Main_Mobile
 disable trigger all  --禁用触发器
 
 merge Item_Insurance..Main_Mobile m
 using (select * from inserted where 是CATI=1
 and Item_Insurance.dbo.f_is_mobile(mobile)=1) s
 on m.mobile=s.mobile
 when matched
 then update set
 m.pt_id=
 (case s.PCT_ID when -1 then 2 when 0 then 1 end)
 ,m.test_date=s.Test_Time
 when not matched
 then insert (mobile,pt_id,test_date,mly_id)
 values(s.mobile,(case s.PCT_ID when -1 then 2 when 0 then 1 end),Test_Time,145) ;
 print 'CATI测号更新Item_Insurance..Main_Mobile'+convert(varchar,@@rowcount)+'条!'
 alter table Item_Insurance..Main_Mobile
 enable trigger all --启用触发器
    end
END

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值