Triggers Usage [Home]

CREATE TRIGGER MinMax ON [dbo].[Supply]
FOR INSERT, UPDATE
AS
DECLARE @min AS FLOAT
DECLARE @max AS FLOAT
SELECT @min = MinValue FROM INSERTED
SELECT @max = MaxValue FROM INSERTED
IF @min > @max
BEGIN
RAISERROR ('ERROR! Minimum value must be less than Maximum value!', 16, 1)
ROLLBACK TRANSACTION
END