I don't know how to use if else in this case. When score > 10, stop insert. Else continue insert as normally. But what a sytax to use that? help me.
CREATE TRIGGER invalidScore ON dbo.dbo_score
AFTER INSERT
AS
DECLARE @score DECIMAL;
SET @score = (SELECT s.score FROM Inserted s);
IF(@score > 10)
BEGIN
RETURN 'score must be less than 10'
ROLLBACK TRAN
END
ELSE
BEGIN
END
Aucun commentaire:
Enregistrer un commentaire