Friday, August 29, 2014

Need help to Create a TRIGGER

You might have to create an INSTEAD OF trigger for this


so something like



CREATE TRIGGER Trg_Codes
INSTEAD OF INSERT
AS
BEGIN
INSERT Codes
SELECT <columns here>
FROM INSERTED i
WHERE NOT EXISTS (SELECT 1
FROM Codes
WHERE PCode = i.PCode
AND GCode = i.GCode
AND DCode = i.DCode
AND SCode = i.SCode
AND CCode = i.CCode
AND (EffectiveDate BETWEEN i.EffectiveDate AND i.TermDate
OR TermDate BETWEEN i.EffectiveDate AND i.TermDate)
)
END





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment