(四)触发器模板
CREATE/ALTER TRIGGER [diyqql_all_SO] ON [dbo].[SEOrderEntry]
FOR INSERT, UPDATE
AS
BEGIN
UPDATE A
SET a.FEntrySelfS0153 =b.fbase
,a.FEntrySelfS0154 =b.fbase1
from inserted m
INNER JOIN SEOrderEntry a on a.finterid=m.finterid and a.fentryid=m.fentryid
inner join t_rpContractEntry b on a.FSourceInterId=b.fcontractid and a.fitemid=b.fproductid
END
GO
--停用触发器
ALTER TABLE SEOrderEntry DISABLE TRIGGER diyqql_all_SO
--启用触发器
ALTER TABLE SEOrderEntry ENABLE TRIGGER diyqql_all_SO
--检查触发器的启用/停用状态
SELECT so_tr.name AS TriggerName, so_tbl.name AS TableName, t.TABLE_SCHEMA AS TableSchema
, case so_tr.status&power(2,11) when power(2,11) then '禁用' else '启用' end as 状态
FROM sysobjects so_tr
INNER JOIN sysobjects so_tbl ON so_tr.parent_obj = so_tbl.id
INNER JOIN INFORMATION_SCHEMA.TABLES t ON t.TABLE_NAME = so_tbl.name
WHERE so_tr.type ='TR' and t.TABLE_NAME='SEOrderEntry'