1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
CREATE TRIGGER TR_IOF_I_Table_RECP
ON Table_RECP
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON
INSERT INTO dbo.Table_RECP
(
RecordID
, ParentID
, SequenceNumber
, Chaintime
, TimeStmp
, MessageText
, Audience
, Severity
, Verbosity
, Location
, Provider
, UserID
, UserFullName
)
SELECT RecordID
, ParentID
, SequenceNumber
, Chaintime
, TimeStmp
, MessageText
, Audience
, Severity
, Verbosity
, Location
, Provider
, UserID
, UserFullName
FROM inserted AS I
CROSS APPLY (
SELECT CASE WHEN SUM(exclude_flag) > 0 THEN 1 ELSE 0 END AS exclude_flag
FROM (
SELECT CASE WHEN I.MessageText LIKE '%' + M.mot + '%' THEN 1 ELSE 0 END AS exclude_flag
FROM dbo.mot_noir AS M
) AS S
) AS E
WHERE E.exclude = 0
END |