--=========================================
-- 门禁数据新增触发器:
-- 门禁数据在新增数据时,过滤DEVICE_NAME!='3栋3楼-前门’的新增操作
-- 数据插入只支持DEVICE NAME-·3栋3楼-前门'的数据插入
--=========================================
USE 门禁考勤
GO
IF EXISTS(SELECT *FROM sys.triggers WHERE name = N'Triger_Insert_filter')
DROP TRIGGER Triger_Insert_Filter
GO
CREATE TRIGGER Triger_Insert_Filter ON [门禁数据]
after Insert
AS
begin
IF EXISTS(select l from inserted where DEVICE_NAME!='3栋3楼-前门')
begin
RAISERROR('Data DEVICE NAME is not 3栋3楼-前门,Insertion aborted',16,1)
ROLLBACK TRANSACTION
END
END