var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Triggers in MS SQL
Could anyone point me to a site that gives a basic tutorial on PL/SQL in MS SQL Server. I know nothing about the syntax, though I am slightly familiar with Oracle PL/SQL.
My present problem is I need to terminate an insert based on an if condition. I have managed to RAISERROR. But the insert still goes through. Here's the block:
CREATE TRIGGER PACKAGE_TRIGGER ON PACKAGES
FOR INSERT AS
DECLARE @LOWER NUMERIC
DECLARE @UPPER NUMERIC
SELECT @LOWER = Lower from Inserted
SELECT @UPPER = Upper from Inserted
IF @LOWER > @UPPER
RAISERROR ('Message number lower limit greater than upper limit', 16, 1)
Is there a more elegant way of doing this?
Thanks in advance for the help.
You can enforce this with a constraint which is probably simpler:
ALTER TABLE TEST1
ADD CONSTRAINT UPR_GRTR_LWR CHECK ([upper] > [lower])
Thanks a lot for the suggestion. I didnt know you could have constraints like this.