标签:SQL
--------------------------------------创建触发器-----------------------------------------------------------------------------
USE [TEST]
GO
CREATE trigger _Name --名称
--ALTER 修改
on COPTD --表名
for INSERT,UPDATE,DELETE --INSERT,UPDATE 对应 Inserted 表 ,DELETE 对应 deleted 表
-- Instead Of INSERT --插入数据前
as
BEGIN
DECLARE @TD001 char(4)
SELECT @TD001 = TD001 from Inserted --赋值
if exists(select UDF11 from INVMB where MB001 = @TD001 and UDF11 = ‘N‘)
BEGIN
INSERT INTO COPTDLog (TD001) VALUES (@TD001)
END
END
-------------------------------------------------------------------------------------------------------------------
标签:SQL
原文地址:http://blog.51cto.com/gongxi/2103150